DummyUserPasswordEncoder::isPasswordValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the BenGorUser package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorUser\User\Infrastructure\Security;
14
15
use BenGorUser\User\Domain\Model\UserPassword;
16
use BenGorUser\User\Domain\Model\UserPasswordEncoder;
17
18
/**
19
 * Dummy user password encoder class for testing purposes.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 * @author Gorka Laucirica <[email protected]>
23
 */
24
final class DummyUserPasswordEncoder implements UserPasswordEncoder
25
{
26
    /**
27
     * The expected response.
28
     *
29
     * @var string
30
     */
31
    private $expectedResponse;
32
33
    /**
34
     * Is password valid boolean.
35
     *
36
     * @var bool
37
     */
38
    private $isPasswordValid;
39
40
    /**
41
     * Constructor.
42
     *
43
     * @param string $expectedResponse The expected response
44
     * @param bool   $isPasswordValid  Is password valid boolean, by default is true
45
     */
46
    public function __construct($expectedResponse, $isPasswordValid = true)
47
    {
48
        $this->expectedResponse = $expectedResponse;
49
        $this->isPasswordValid = $isPasswordValid;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function encode($aPlainPassword, $aSalt)
56
    {
57
        return $this->expectedResponse;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function isPasswordValid(UserPassword $anEncoded, $aPlainPassword)
64
    {
65
        return $this->isPasswordValid;
66
    }
67
}
68