LoginUserCommand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 93
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A email() 0 4 1
A setEmail() 0 4 1
A password() 0 4 1
A setPassword() 0 4 1
A isLogin() 0 4 1
A setLogin() 0 4 1
A loadValidatorMetadata() 0 12 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Cqrs\Tests\Fixtures\Command;
12
13
use Cubiche\Core\Cqrs\Command\CommandInterface;
14
use Cubiche\Core\Validator\Assert;
15
use Cubiche\Core\Validator\Mapping\ClassMetadata;
16
17
/**
18
 * LoginUserCommand class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class LoginUserCommand implements CommandInterface
23
{
24
    /**
25
     * @var string
26
     */
27
    protected $email;
28
29
    /**
30
     * @var string
31
     */
32
    protected $password;
33
34
    /**
35
     * @var bool
36
     */
37
    protected $login = false;
38
39
    /**
40
     * LoginUserCommand constructor.
41
     *
42
     * @param $email
43
     * @param $password
44
     */
45
    public function __construct($email, $password)
46
    {
47
        $this->setEmail($email);
48
        $this->setPassword($password);
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function email()
55
    {
56
        return $this->email;
57
    }
58
59
    /**
60
     * @param string $email
61
     */
62
    public function setEmail($email)
63
    {
64
        $this->email = $email;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function password()
71
    {
72
        return $this->password;
73
    }
74
75
    /**
76
     * @param string $password
77
     */
78
    public function setPassword($password)
79
    {
80
        $this->password = $password;
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function isLogin()
87
    {
88
        return $this->login;
89
    }
90
91
    /**
92
     * @param bool $login
93
     */
94
    public function setLogin($login)
95
    {
96
        $this->login = $login;
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public static function loadValidatorMetadata(ClassMetadata $classMetadata)
103
    {
104
        $classMetadata->addPropertyConstraint(
105
            'email',
106
            Assert::email()
0 ignored issues
show
Compatibility introduced by
\Cubiche\Core\Validator\Assert::email() of type object<Respect\Validation\Validator> is not a sub-type of object<Cubiche\Core\Validator\Assert>. It seems like you assume a child class of the class Respect\Validation\Validator to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
107
        );
108
109
        $classMetadata->addPropertyConstraint(
110
            'password',
111
            Assert::stringType()->notBlank()
112
        );
113
    }
114
}
115