| Total Complexity | 8 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | abstract class Activation extends \yii\base\Model |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * The activation code |
||
| 18 | * @var string $activation_code |
||
| 19 | */ |
||
| 20 | public $activation_code; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The user associated to the model |
||
| 24 | * @var User $user |
||
|
|
|||
| 25 | */ |
||
| 26 | private $user; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Validation rules |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | public function rules() |
||
| 33 | { |
||
| 34 | return [ |
||
| 35 | [['activation_code'], 'required'], |
||
| 36 | [['activation_code'], 'belongsToUserAndIsNotExpired'] |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Validates that the activation code belongs to a user and is not expired |
||
| 42 | * @param string $attribute |
||
| 43 | * @param array $params |
||
| 44 | */ |
||
| 45 | public function belongsToUserAndIsNotExpired($attribute, $params) |
||
| 46 | { |
||
| 47 | if (!$this->hasErrors()) { |
||
| 48 | $code = Code::find()->where([ |
||
| 49 | 'hash' => hash('sha256', $this->activation_code . '_activation_token') |
||
| 50 | ])->one(); |
||
| 51 | |||
| 52 | if ($code === null) { |
||
| 53 | $this->addError('activation_code', Yii::t('yrc', 'The activation code provided is not valid.')); |
||
| 54 | return; |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->user = Yii::$app->user->identityClass::find()->where(['id' => $code->user_id])->one(); |
||
| 58 | |||
| 59 | if ($this->user === null) { |
||
| 60 | $this->addError('activation_code', Yii::t('yrc', 'The activation code provided is not valid.')); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Activates the user |
||
| 67 | * @return boolean |
||
| 68 | */ |
||
| 69 | public function activate() |
||
| 80 | } |
||
| 81 | } |
||
| 82 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths