Total Complexity | 6 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
15 | class EmailConfirmForm extends Model |
||
16 | { |
||
17 | /** |
||
18 | * @var User|bool |
||
19 | */ |
||
20 | private $user; |
||
21 | |||
22 | /** |
||
23 | * Creates a form model given a token. |
||
24 | * |
||
25 | * @param mixed $token |
||
26 | * @param array $config |
||
27 | * @throws InvalidArgumentException if token is empty or not valid |
||
28 | */ |
||
29 | public function __construct($token = '', $config = []) |
||
30 | { |
||
31 | if (empty($token) || !is_string($token)) { |
||
32 | throw new InvalidArgumentException(Module::t( |
||
33 | 'module', |
||
34 | 'Email confirm token cannot be blank.' |
||
35 | )); |
||
36 | } |
||
37 | $this->user = User::findByEmailConfirmToken($token); |
||
38 | if (!$this->user) { |
||
39 | throw new InvalidArgumentException(Module::t('module', 'Wrong Email confirm token.')); |
||
40 | } |
||
41 | parent::__construct($config); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Confirm email. |
||
46 | * |
||
47 | * @return bool|Assignment if email was confirmed. |
||
48 | * @throws Exception |
||
49 | */ |
||
50 | public function confirmEmail() |
||
59 | } |
||
60 | } |
||
61 |