1 | <?php |
||
19 | class Server extends Main |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * POST request handler |
||
24 | * |
||
25 | * @param string $path The path name to match against. |
||
26 | * @param mixed $to Callback that returns the response when matched. |
||
27 | * @see Server::proxy |
||
28 | * @return Controller Provides a fluent interface. |
||
29 | */ |
||
30 | public function onCreate($path, $to) |
||
31 | { |
||
32 | return $this->proxy('POST', $path, $to); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * GET request handler |
||
37 | * |
||
38 | * @param string $path The path name to match against. |
||
39 | * @param mixed $to Callback that returns the response when matched. |
||
40 | * @see Server::proxy |
||
41 | * @return Controller Provides a fluent interface. |
||
42 | */ |
||
43 | public function onRead($path, $to) |
||
44 | { |
||
45 | return $this->proxy('GET', $path, $to); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * PUT request handler |
||
50 | * |
||
51 | * @param string $path The path name to match against. |
||
52 | * @param mixed $to Callback that returns the response when matched. |
||
53 | * @see Server::proxy |
||
54 | * @return Controller Provides a fluent interface. |
||
55 | */ |
||
56 | public function onUpdate($path, $to) |
||
57 | { |
||
58 | return $this->proxy('PUT', $path, $to); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * PATCH request handler |
||
63 | * |
||
64 | * @param string $path The path name to match against. |
||
65 | * @param mixed $to Callback that returns the response when matched. |
||
66 | * @see Server::proxy |
||
67 | * @return Controller Provides a fluent interface. |
||
68 | */ |
||
69 | public function onModify($path, $to) |
||
70 | { |
||
71 | return $this->proxy('PATCH', $path, $to); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * DELETE request handler |
||
76 | * |
||
77 | * @param string $path The path name to match against. |
||
78 | * @param mixed $to Callback that returns the response when matched. |
||
79 | * @see Server::proxy |
||
80 | * @return Controller Provides a fluent interface. |
||
81 | */ |
||
82 | public function onDelete($path, $to) |
||
83 | { |
||
84 | return $this->proxy('DELETE', $path, $to); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * OPTIONS request handler |
||
89 | * |
||
90 | * @param string $path The path name to match against. |
||
91 | * @param mixed $to Callback that returns the response when matched. |
||
92 | * @see Server::proxy |
||
93 | * @return Controller Provides a fluent interface. |
||
94 | */ |
||
95 | public function onHelp($path, $to) |
||
96 | { |
||
97 | return $this->proxy('OPTIONS', $path, $to); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * HEAD request handler |
||
102 | * |
||
103 | * @param string $path The path name to match against. |
||
104 | * @param mixed $to Callback that returns the response when matched. |
||
105 | * @see Server::proxy |
||
106 | * @return Controller Provides a fluent interface. |
||
107 | */ |
||
108 | public function onTest($path, $to) |
||
109 | { |
||
110 | return $this->proxy('HEAD', $path, $to); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Acts as a shortcut to resources::add. |
||
115 | * @see Resources::add |
||
116 | * |
||
117 | * @param string $method The HTTP method to match against. |
||
118 | * @param string $path The path name to match against. |
||
119 | * @param mixed $to Callback that returns the response |
||
120 | * when matched. |
||
121 | * @return Controller |
||
122 | */ |
||
123 | protected function proxy($method, $path, \Closure $to) |
||
124 | { |
||
125 | return $this->resources->add($path, |
||
126 | array( |
||
127 | 'action' => $to, |
||
128 | 'method' => $method |
||
129 | ) |
||
130 | ); |
||
131 | } |
||
132 | |||
133 | // public function setGroupInfo($path, array $docs=null) |
||
|
|||
134 | // { |
||
135 | // var_dump( $this->resources); exit; |
||
136 | // $this->group = $infos; |
||
137 | // } |
||
138 | |||
139 | /** |
||
140 | * TODO: Test Read from a group. |
||
141 | * |
||
142 | * @param array $opts Options are: |
||
143 | * @return string |
||
144 | * @codeCoverageIgnore |
||
145 | */ |
||
146 | public function setGroup($name, array $groupInfo=null) |
||
150 | |||
151 | } |
||
152 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.