1 | <?php |
||
18 | class CacheWare |
||
19 | { |
||
20 | const CACHE_PUBLIC = 'limit'; |
||
21 | const CACHE_PRIVATE = 'private'; |
||
22 | const CACHE_PRIVATE_NO_EXPIRE = 'private_no_expire'; |
||
23 | const CACHE_NOCACHE = 'nocache'; |
||
24 | |||
25 | const CACHE_EXPIRED = 'Thu, 19 Nov 1981 08:52:00 GMT'; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $settings; |
||
31 | |||
32 | /** |
||
33 | * Middleware constructor. |
||
34 | * |
||
35 | * @param array $settings |
||
36 | */ |
||
37 | public function __construct(array $settings = []) |
||
41 | |||
42 | /** |
||
43 | * Execute the middleware. |
||
44 | * |
||
45 | * @param ServerRequestInterface $request |
||
46 | * @param ResponseInterface $response |
||
47 | * @param callable $next |
||
48 | * |
||
49 | * @throws \InvalidArgumentException |
||
50 | * @throws \RuntimeException |
||
51 | * |
||
52 | * @return ResponseInterface |
||
53 | */ |
||
54 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
69 | |||
70 | /** |
||
71 | * Retrieve default cache settings. |
||
72 | * |
||
73 | * @return array |
||
|
|||
74 | */ |
||
75 | protected function getCacheSettings() |
||
82 | |||
83 | /** |
||
84 | * Add corresponding cache headers to response. |
||
85 | * |
||
86 | * @param array $settings |
||
87 | * @param ResponseInterface $response |
||
88 | * |
||
89 | * @throws \InvalidArgumentException |
||
90 | * |
||
91 | * @return ResponseInterface |
||
92 | */ |
||
93 | protected function respondWithCacheHeaders(array $settings, ResponseInterface $response) |
||
111 | |||
112 | /** |
||
113 | * Add public cache headers to response. |
||
114 | * |
||
115 | * @param array $settings |
||
116 | * @param ResponseInterface $response |
||
117 | * |
||
118 | * @throws \InvalidArgumentException |
||
119 | * |
||
120 | * @return ResponseInterface |
||
121 | */ |
||
122 | protected function respondWithPublicCache(array $settings, ResponseInterface $response) |
||
138 | |||
139 | /** |
||
140 | * Add private cache headers to response. |
||
141 | * |
||
142 | * @param array $settings |
||
143 | * @param ResponseInterface $response |
||
144 | * |
||
145 | * @throws \InvalidArgumentException |
||
146 | * |
||
147 | * @return ResponseInterface |
||
148 | */ |
||
149 | protected function respondWithPrivateCache(array $settings, ResponseInterface $response) |
||
156 | |||
157 | /** |
||
158 | * Add private-no-expire cache headers to response. |
||
159 | * |
||
160 | * @param array $settings |
||
161 | * @param ResponseInterface $response |
||
162 | * |
||
163 | * @throws \InvalidArgumentException |
||
164 | * |
||
165 | * @return ResponseInterface |
||
166 | */ |
||
167 | protected function respondWithPrivateNoExpireCache(array $settings, ResponseInterface $response) |
||
176 | |||
177 | /** |
||
178 | * Add no-cache cache headers to response. |
||
179 | * |
||
180 | * @param ResponseInterface $response |
||
181 | * |
||
182 | * @throws \InvalidArgumentException |
||
183 | * |
||
184 | * @return ResponseInterface |
||
185 | */ |
||
186 | protected function respondWithNoCacheCache(ResponseInterface $response) |
||
193 | } |
||
194 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.