Test Setup Failed
Push — master ( 67c757...e205b4 )
by Php Easy Api
03:32
created

AuthenticateRequest::rule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Authenticate;
4
5
use Resta\Authenticate\Resource\AuthLoginCredentialsManager;
6
use Resta\Request\Request as RequestClient;
7
8
class AuthenticateRequest extends RequestClient
9
{
10
    /**
11
     * With the auto injector,
12
     * all the indices in the array are executed as methods
13
     * and the global input is automatically injected.
14
     *
15
     * @var array $autoInject
16
     */
17
    protected $autoInject = [];
18
19
    /**
20
     * The values ​​expected by the server.
21
     *
22
     * @var array
23
     */
24
    protected $expected = [];
25
26
    /**
27
     * mandatory http method.
28
     *
29
     * @var array
30
     */
31
    protected $http = [];
32
33
    /**
34
     * @var null|object
35
     */
36
    protected $credentials;
37
38
    /**
39
     * AuthenticateRequest constructor.
40
     * @param AuthLoginCredentialsManager $credentials
41
     */
42
    public function __construct($credentials)
43
    {
44
        $this->credentials = $credentials;
45
46
        //credentials loop for expected property
47
        foreach ($this->credentials->get() as $credential){
48
            $this->expected[] = $credential;
49
        }
50
51
        parent::__construct();
52
    }
53
54
    /**
55
     * @param $credentials
56
     */
57
    public function credentials($credentials)
0 ignored issues
show
Unused Code introduced by
The parameter $credentials is not used and could be removed. ( Ignorable by Annotation )

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

57
    public function credentials(/** @scrutinizer ignore-unused */ $credentials)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
        $credentials = [];
60
61
        foreach ($this->inputs as $inputKey=>$inputValue){
62
63
            if(in_array($inputKey,$this->expected)){
64
                $credentials[$inputKey] = $inputValue;
65
            }
66
        }
67
68
        return $credentials;
69
    }
70
71
    /**
72
     * @var string
73
     */
74
    protected $password;
75
76
    /**
77
     * @return string
78
     */
79
    protected function password()
80
    {
81
        return md5(sha1($this->password));
82
    }
83
}