Completed
Push — master ( 83bf39...45b9bd )
by Sergey
02:26
created

RequestObject   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 53
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setPayload() 0 4 1
A rules() 0 4 1
A validationGroup() 0 4 1
A get() 0 5 2
A has() 0 4 1
A all() 0 4 1
1
<?php
2
3
namespace Fesor\RequestObject;
4
5
class RequestObject
6
{
7
    private $payload;
8
9
    public function setPayload(array $payload = [])
10
    {
11
        $this->payload = $payload;
12
    }
13
14
    /**
15
     * @inheritdoc
16
     */
17
    public function rules()
18
    {
19
        return null;
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function validationGroup(array $payload)
0 ignored issues
show
Unused Code introduced by
The parameter $payload is not used and could be removed.

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

Loading history...
26
    {
27
        return null;
28
    }
29
30
    /**
31
     * @param string $name
32
     * @param mixed|null $default
33
     * @return mixed
34
     */
35
    public function get($name, $default = null)
36
    {
37
        return $this->has($name) ?
38
            $this->payload[$name] : $default;
39
    }
40
41
    /**
42
     * @param string $name
43
     * @return bool
44
     */
45
    public function has($name)
46
    {
47
        return array_key_exists($name, $this->payload);
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function all()
54
    {
55
        return $this->payload;
56
    }
57
}