Completed
Push — master ( b2e200...1332b8 )
by Oscar
04:48
created

Gzip::deflate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 9
loc 9
rs 9.6667
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace Psr7Middlewares\Transformers;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr7Middlewares\Middleware;
7
8
/**
9
 * Generic resolver to gzip compression.
10
 */
11
class Gzip extends Resolver
12
{
13
    /**
14
     * Gzip minifier using gzencode().
15
     * 
16
     * @param ResponseInterface $response
17
     * 
18
     * @return ResponseInterface
19
     */
20 View Code Duplication
    public function gzip(ResponseInterface $response)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
21
    {
22
        $stream = Middleware::createStream();
23
        $stream->write(gzencode((string) $response->getBody()));
24
25
        return $response
26
            ->withHeader('Content-Encoding', 'gzip')
27
            ->withBody($stream);
28
    }
29
30
    /**
31
     * Gzip minifier using gzdeflate().
32
     * 
33
     * @param ResponseInterface $response
34
     * 
35
     * @return ResponseInterface
36
     */
37 View Code Duplication
    public function deflate(ResponseInterface $response)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
38
    {
39
        $stream = Middleware::createStream();
40
        $stream->write(gzdeflate((string) $response->getBody()));
41
42
        return $response
43
            ->withHeader('Content-Encoding', 'deflate')
44
            ->withBody($stream);
45
    }
46
}
47