AdapterChainEvent::setCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace LmcUser\Authentication\Adapter;
4
5
use Laminas\EventManager\Event;
6
use Laminas\Stdlib\RequestInterface as Request;
7
8
class AdapterChainEvent extends Event
9
{
10
    /**
11
     * getIdentity
12
     *
13
     * @return mixed
14
     */
15
    public function getIdentity()
16
    {
17
        return $this->getParam('identity');
18
    }
19
20
    /**
21
     * setIdentity
22
     *
23
     * @param  mixed $identity
24
     * @return AdapterChainEvent
25
     */
26
    public function setIdentity($identity = null)
27
    {
28
        if (null === $identity) {
29
            // Setting the identity to null resets the code and messages.
30
            $this->setCode();
31
            $this->setMessages();
32
        }
33
        $this->setParam('identity', $identity);
34
        return $this;
35
    }
36
37
    /**
38
     * getCode
39
     *
40
     * @return int
41
     */
42
    public function getCode()
43
    {
44
        return $this->getParam('code');
45
    }
46
47
    /**
48
     * setCode
49
     *
50
     * @param  int $code
51
     * @return AdapterChainEvent
52
     */
53
    public function setCode($code = null)
54
    {
55
        $this->setParam('code', $code);
56
        return $this;
57
    }
58
59
    /**
60
     * getMessages
61
     *
62
     * @return array
63
     */
64
    public function getMessages()
65
    {
66
        return $this->getParam('messages') ?: array();
67
    }
68
69
    /**
70
     * setMessages
71
     *
72
     * @param  array $messages
73
     * @return AdapterChainEvent
74
     */
75
    public function setMessages($messages = array())
76
    {
77
        $this->setParam('messages', $messages);
78
        return $this;
79
    }
80
81
    /**
82
     * getRequest
83
     *
84
     * @return Request
85
     */
86
    public function getRequest()
87
    {
88
        return $this->getParam('request');
89
    }
90
91
    /**
92
     * setRequest
93
     *
94
     * @param  Request $request
95
     * @return AdapterChainEvent
96
     */
97
    public function setRequest(Request $request)
98
    {
99
        $this->setParam('request', $request);
100
        $this->request = $request;
0 ignored issues
show
Bug introduced by
The property request does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
101
        return $this;
102
    }
103
}
104