1 | <?php |
||
28 | class RequestManager implements RequestManagerInterface |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $requests = array(); |
||
35 | |||
36 | /** |
||
37 | * @inheritdoc |
||
38 | */ |
||
39 | 2 | public function getRequest($name) |
|
40 | { |
||
41 | 2 | if ($this->requestExists($name)) { |
|
42 | 1 | return $this->requests[$name]; |
|
43 | } |
||
44 | |||
45 | 1 | return null; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | */ |
||
51 | 5 | public function hasRequest($name) |
|
52 | { |
||
53 | 5 | return $this->requestExists($name); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | 2 | public function removeRequest($name) |
|
60 | { |
||
61 | 2 | if ($this->requestExists($name)) { |
|
62 | 1 | unset($this->requests[$name]); |
|
63 | |||
64 | 1 | return true; |
|
65 | } |
||
66 | |||
67 | 1 | return false; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 1 | public function reset() |
|
74 | { |
||
75 | 1 | $this->requests = array(); |
|
76 | 1 | } |
|
77 | |||
78 | /** |
||
79 | * @inheritdoc |
||
80 | */ |
||
81 | 6 | public function setRequest($name, RequestInterface $request) |
|
82 | { |
||
83 | 6 | if ($this->requestExists($name)) { |
|
84 | 1 | throw new RequestManagerException('a request for "' . $name . '" is already registered'); |
|
85 | } |
||
86 | |||
87 | 6 | $this->requests[$name] = $request; |
|
88 | 6 | } |
|
89 | |||
90 | /** |
||
91 | * checks if a request is registered for given name |
||
92 | * |
||
93 | * @param string $name |
||
94 | * |
||
95 | * @return bool |
||
96 | * @author Daniel Wendlandt |
||
97 | */ |
||
98 | 9 | private function requestExists($name) |
|
102 | } |
||
103 |