UserStore.php 896 Bytes
<?php
namespace common\components;

use yii\base\Exception;

class UserStore {

    private $users = [];

    function addUser( $name, $email, $pass){
        if(isset($this->users[$email])){
            throw new Exception("Пользователь {$email} уже зарегистрирован");
        }

        if (strlen($pass) < 5 ){
            throw new Exception(
                "Длинна пароля должна быть больше 5 символов"
            );
        }

        $this->users[$email] = [
            'pass' => $pass,
            'email' => $email,
            'name' => $name
        ];

        return true;
    }

    function notifyPasswordFailure($email){
        if(isset($this->users[$email])){
            $this->users[$email]['failed'] = time();
        }
    }

    function getUser($email){
        return ($this->users[$email]);
    }



}