RecoverPasswordFormTrait::processValidationEmail()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 13
rs 9.6111
ccs 0
cts 10
cp 0
cc 5
nc 4
nop 0
crap 30
1
<?php
2
3
namespace ByTIC\Hello\Modules\AbstractModule\Forms\Users;
4
5
/**
6
 * Trait RecoverPasswordFormTrait
7
 * @package ByTIC\Hello\Modules\AbstractModule\Forms\Users
8
 */
9
trait RecoverPasswordFormTrait
10
{
11
    public function init()
12
    {
13
        parent::init();
14
        $this->removeClass('form-horizontal');
0 ignored issues
show
Bug introduced by
It seems like removeClass() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        $this->/** @scrutinizer ignore-call */ 
15
               removeClass('form-horizontal');
Loading history...
15
        $this->addClass('user-recover');
0 ignored issues
show
Bug introduced by
It seems like addClass() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
        $this->/** @scrutinizer ignore-call */ 
16
               addClass('user-recover');
Loading history...
16
17
        $this->initEmailInput();
18
19
        $this->addButton('save', translator()->trans('submit'));
0 ignored issues
show
Bug introduced by
It seems like addButton() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $this->/** @scrutinizer ignore-call */ 
20
               addButton('save', translator()->trans('submit'));
Loading history...
20
    }
21
22
    protected function initEmailInput()
23
    {
24
        $this->addInput('email', translator()->trans('email'), true);
0 ignored issues
show
Bug introduced by
It seems like addInput() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $this->/** @scrutinizer ignore-call */ 
25
               addInput('email', translator()->trans('email'), true);
Loading history...
25
    }
26
27
    public function processValidation()
28
    {
29
        parent::processValidation();
30
31
        $this->processValidationEmail();
32
    }
33
34
    public function processValidationEmail()
35
    {
36
        $email = $this->getElement('email');
0 ignored issues
show
Bug introduced by
It seems like getElement() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        /** @scrutinizer ignore-call */ 
37
        $email = $this->getElement('email');
Loading history...
37
        if (!$email->isError()) {
38
            $value = $email->getValue();
39
            if (!valid_email($value) && false) {
0 ignored issues
show
Bug introduced by
The function valid_email was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
            if (!/** @scrutinizer ignore-call */ valid_email($value) && false) {
Loading history...
40
                $email->addError($this->getModelMessage('email.bad'));
0 ignored issues
show
Bug introduced by
It seems like getModelMessage() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
                $email->addError($this->/** @scrutinizer ignore-call */ getModelMessage('email.bad'));
Loading history...
41
            } else {
42
                $users = $this->getModelManager()->findByEmail($value);
0 ignored issues
show
Bug introduced by
It seems like getModelManager() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
                $users = $this->/** @scrutinizer ignore-call */ getModelManager()->findByEmail($value);
Loading history...
43
                if (count($users) == 1) {
44
                    $this->getModel()->email = $value;
0 ignored issues
show
Bug introduced by
It seems like getModel() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
                    $this->/** @scrutinizer ignore-call */ 
45
                           getModel()->email = $value;
Loading history...
45
                } else {
46
                    $email->addError($this->getModelMessage('email.dnx'));
47
                }
48
            }
49
        }
50
    }
51
52
    public function process()
53
    {
54
        $this->getModel()->recoverPassword();
55
    }
56
57
    protected function getDataFromModel()
58
    {
59
        parent::getDataFromModel();
60
        $this->_addModelFormMessage('no-email', 'email.empty');
0 ignored issues
show
Bug introduced by
It seems like _addModelFormMessage() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        $this->/** @scrutinizer ignore-call */ 
61
               _addModelFormMessage('no-email', 'email.empty');
Loading history...
61
    }
62
}
63