PixelResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createBody() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Common\Response;
6
7
use Fig\Http\Message\StatusCodeInterface as StatusCode;
8
use Laminas\Diactoros\Response;
9
use Laminas\Diactoros\Stream;
10
use Psr\Http\Message\StreamInterface;
11
12
use function base64_decode;
13
14
class PixelResponse extends Response
15
{
16
    private const BASE_64_IMAGE = 'R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==';
17
    private const CONTENT_TYPE = 'image/gif';
18
19 1
    public function __construct(int $status = StatusCode::STATUS_OK, array $headers = [])
20
    {
21 1
        $headers['content-type'] = self::CONTENT_TYPE;
22 1
        parent::__construct($this->createBody(), $status, $headers);
23
    }
24
25 1
    private function createBody(): StreamInterface
26
    {
27 1
        $body = new Stream('php://temp', 'wb+');
28 1
        $body->write(base64_decode(self::BASE_64_IMAGE));
29 1
        $body->rewind();
30 1
        return $body;
31
    }
32
}
33