PngWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 33
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContentType() 0 4 1
A imageToString() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/qrcode-library project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\QrCode\Writer;
13
14
use BaconQrCode\Renderer\Image\Png;
15
use Da\QrCode\Traits\ImageTrait;
16
17
class PngWriter extends AbstractWriter
18
{
19
    use ImageTrait;
20
21
    /**
22
     * PngWriter constructor.
23
     */
24
    public function __construct()
25
    {
26
        parent::__construct(new Png());
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function getContentType(): string
33
    {
34
        return 'image/png';
35
    }
36
37
    /**
38
     * @param resource $image
39
     *
40
     * @return string
41
     */
42
    protected function imageToString($image): string
43
    {
44
        ob_start();
45
        imagepng($image);
46
47
        return ob_get_clean();
48
    }
49
}
50