1 | <?php |
||
38 | abstract class AbstractResponderLocator |
||
39 | { |
||
40 | /** |
||
41 | * Responder factories |
||
42 | * |
||
43 | * @var array |
||
44 | * |
||
45 | * @access protected |
||
46 | */ |
||
47 | protected $factories = []; |
||
48 | |||
49 | /** |
||
50 | * Create a responder locator |
||
51 | * |
||
52 | * @param array $factories factories to create responders |
||
53 | * |
||
54 | * @access public |
||
55 | */ |
||
56 | 5 | public function __construct(array $factories) |
|
60 | |||
61 | /** |
||
62 | * Negotiate and respond |
||
63 | * |
||
64 | * @param Request $request PSR7 Request |
||
65 | * @param Response $response PSR7 Response |
||
66 | * @param PayloadInterface $payload Domain Payload |
||
67 | * |
||
68 | * @return Response |
||
69 | * |
||
70 | * @access public |
||
71 | */ |
||
72 | 4 | public function __invoke( |
|
91 | |||
92 | /** |
||
93 | * Accepts |
||
94 | * |
||
95 | * @return array |
||
96 | * |
||
97 | * @access public |
||
98 | */ |
||
99 | 2 | public function accepts() |
|
103 | |||
104 | /** |
||
105 | * Unavailable |
||
106 | * |
||
107 | * @return Response |
||
108 | * |
||
109 | * @access protected |
||
110 | */ |
||
111 | 1 | protected function notAcceptable() |
|
118 | |||
119 | /** |
||
120 | * Set |
||
121 | * |
||
122 | * @param string $name name/type of responder |
||
123 | * @param calable $callable factory |
||
124 | * |
||
125 | * @return $this |
||
126 | * |
||
127 | * @access public |
||
128 | */ |
||
129 | 1 | public function set($name, callable $callable) |
|
134 | /** |
||
135 | * Does a named helper exist? |
||
136 | * |
||
137 | * @param string $name The responder name. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | 5 | public function has($name) |
|
145 | |||
146 | /** |
||
147 | * Get a responder |
||
148 | * |
||
149 | * @param string $name The responder to retrieve. |
||
150 | * |
||
151 | * @return object |
||
152 | */ |
||
153 | 4 | public function get($name) |
|
164 | |||
165 | /** |
||
166 | * Negotiate |
||
167 | * |
||
168 | * @param Request $request PSR7 Request |
||
169 | * |
||
170 | * @return string | false |
||
171 | * |
||
172 | * @access protected |
||
173 | */ |
||
174 | abstract protected function negotiate(Request $request); |
||
175 | } |
||
176 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: