Conditions | 4 |
Paths | 5 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 15 |
Ratio | 100 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
25 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
26 | { |
||
27 | if (!Middleware::hasAttribute($request, FormatNegotiator::KEY)) { |
||
28 | throw new RuntimeException('Minify middleware needs FormatNegotiator executed before'); |
||
29 | } |
||
30 | |||
31 | $resolver = $this->resolver ?: new Transformers\Minifier(); |
||
32 | $transformer = $resolver->resolve(FormatNegotiator::getFormat($request)); |
||
33 | |||
34 | if ($transformer) { |
||
35 | $response = $transformer($response); |
||
36 | } |
||
37 | |||
38 | return $next($request, $response); |
||
39 | } |
||
40 | } |
||
41 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.