Completed
Push — master ( 1f4ad9...320f5c )
by John
03:15
created

AbstractBoxRenderer::factory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Renderer\FieldRenderer\GraphicPrimitive;
4
5
use Graze\CiffRenderer\Renderer\FieldRenderer\FieldRendererInterface;
6
use Intervention\Image\ImageManager;
7
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
8
9
abstract class AbstractBoxRenderer implements FieldRendererInterface
10
{
11
    /**
12
     * @param ImageManager $imageManager
13
     * @param FieldParserInterface $parser
14
     * @param callable $fontResolver
15
     * @param callable $graphicResolver
16
     * @return Intervention\Image\Image
0 ignored issues
show
Bug introduced by
The type Graze\CiffRenderer\Rende...ntervention\Image\Image was not found. Did you mean Intervention\Image\Image? If so, make sure to prefix the type with \.
Loading history...
17
     */
18 1
    public function render(
19
        ImageManager $imageManager,
20
        FieldParserInterface $parser,
21
        callable $fontResolver = null,
22
        callable $graphicResolver = null
23
    ) {
24 1
        $canvas = $imageManager->canvas($parser->getWidth(), $parser->getHeight());
25
26 1
        $rectangleConf = function ($rectangle) use ($parser) {
27 1
            $rectangle->border($parser->getLineWeight(), '#000');
0 ignored issues
show
Bug introduced by
The method getLineWeight() does not exist on Graze\CiffRenderer\Parse...er\FieldParserInterface. It seems like you code against a sub-type of Graze\CiffRenderer\Parse...er\FieldParserInterface such as Graze\CiffRenderer\Parse...dParserGraphicPrimitive or Graze\CiffRenderer\Parse...dParserGraphicPrimitive. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            $rectangle->border($parser->/** @scrutinizer ignore-call */ getLineWeight(), '#000');
Loading history...
28 1
            if ($this->isFilled()) {
29
                $rectangle->background('#000');
30
            }
31 1
        };
32
33 1
        $canvas->rectangle(
34 1
            0,
35 1
            0,
36 1
            $parser->getWidth() - $parser->getLineWeight(),
37 1
            $parser->getHeight() - $parser->getLineWeight(),
38
            $rectangleConf
39 1
        );
40
41 1
        return $canvas;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $canvas returns the type Intervention\Image\Image which is incompatible with the documented return type Graze\CiffRenderer\Rende...ntervention\Image\Image.
Loading history...
42
    }
43
44
    /**
45
     * Is the box filled, or just an outline?
46
     *
47
     * @var bool
48
     */
49
    abstract protected function isFilled();
50
51
    /**
52
     * @return FieldParserInterface
53
     */
54 2
    public static function factory()
55
    {
56 2
        return new static();
0 ignored issues
show
Bug Best Practice introduced by
The expression return new static() returns the type Graze\CiffRenderer\Rende...ive\AbstractBoxRenderer which is incompatible with the documented return type Graze\CiffRenderer\Parse...er\FieldParserInterface.
Loading history...
57
    }
58
}
59