Blame view

common/components/UserStore.php 896 Bytes
fdc1c9de   Yarik   test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  <?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]);
      }
  
  
  
  }