RequestHandler   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 60.87%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 114
ccs 14
cts 23
cp 0.6087
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getName() 0 4 1
A getPath() 0 4 1
A getMethod() 0 4 1
A setDefaultParams() 0 5 1
A setDefaultParam() 0 5 1
A getDefaultParams() 0 4 1
A removeDefaultParam() 0 5 1
1
<?php
2
3
namespace PSolr\Client;
4
5
class RequestHandler
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $name;
11
12
    /**
13
     * @var string
14
     */
15
    protected $path;
16
17
    /**
18
     * @var string
19
     */
20
    protected $method;
21
22
    /**
23
     * @var array
24
     */
25
    protected $defaultParams;
26
27
    /**
28
     * @param type $name
29
     * @param type $path
30
     * @param string $method
31
     * @param array $defaultParams
32
     */
33 28
    public function __construct($name, $path, $method, array $defaultParams = array())
34
    {
35 28
        $this->name = $name;
0 ignored issues
show
Documentation Bug introduced by
It seems like $name of type object<PSolr\Client\type> is incompatible with the declared type string of property $name.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36 28
        $this->path = $path;
0 ignored issues
show
Documentation Bug introduced by
It seems like $path of type object<PSolr\Client\type> is incompatible with the declared type string of property $path.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37 28
        $this->method = strtoupper($method);
38 28
        $this->defaultParams = $defaultParams;
39 28
    }
40
41
    /**
42
     * Returns the name of the method that can be invoked from the client.
43
     *
44
     * @return string
45
     */
46 28
    public function getName()
47
    {
48 28
        return $this->name;
49
    }
50
51
    /**
52
     * Returns the path tp the request handler.
53
     *
54
     * @return string
55
     */
56 4
    public function getPath()
57
    {
58 4
        return $this->path;
59
    }
60
61
    /**
62
     * @return string
63
     */
64 4
    public function getMethod()
65
    {
66 4
        return $this->method;
67
    }
68
69
    /**
70
     * Sets the default parameters for this request handler.
71
     *
72
     * @param array $params
73
     *
74
     * @return \PSolr\Client\RequestHandler
75
     */
76
    public function setDefaultParams(array $params)
77
    {
78
        $this->defaultParams = $params;
79
        return $this;
80
    }
81
82
    /**
83
     * Sets the default parameters for this request handler.
84
     *
85
     * @param string $param
86
     * @param mixed $value
87
     *
88
     * @return \PSolr\Client\RequestHandler
89
     */
90
    public function setDefaultParam($param, $value)
91
    {
92
        $this->defaultParams[$param] = $value;
93
        return $this;
94
    }
95
96
    /**
97
     * Returns the request handler's default parameters.
98
     *
99
     * @return array
100
     */
101 8
    public function getDefaultParams()
102
    {
103 8
        return $this->defaultParams;
104
    }
105
106
    /**
107
     * Sets the default parameters for this request handler.
108
     *
109
     * @param string $param
110
     *
111
     * @return \PSolr\Client\RequestHandler
112
     */
113
    public function removeDefaultParam($param)
114
    {
115
        unset($this->defaultParams[$param]);
116
        return $this;
117
    }
118
}
119