Passed
Push — master ( a3ef5a...1f4ad9 )
by John
03:23
created

AbstractBoxRenderer::render()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2.0758

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
ccs 11
cts 15
cp 0.7332
rs 9.9332
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 2.0758
1
<?php
2
3
namespace Graze\CiffRenderer\Field\Renderer\GraphicPrimitive;
4
5
use Graze\CiffRenderer\Field\Renderer\GraphicPrimitive\AbstractGraphicPrimitiveRenderer;
6
7
abstract class AbstractBoxRenderer extends AbstractGraphicPrimitiveRenderer
8
{
9
    /**
10
     * @return Intervention/Image/Image
0 ignored issues
show
Documentation Bug introduced by
The doc comment Intervention/Image/Image at position 0 could not be parsed: Unknown type name 'Intervention/Image/Image' at position 0 in Intervention/Image/Image.
Loading history...
11
     */
12 1
    public function render()
13
    {
14 1
        $canvas = $this->getImageManager()->canvas($this->getWidth(), $this->getHeight(), $this->getTracerColour());
15
16 1
        $rectangleConf = function ($rectangle) {
17
            $rectangle->border($this->getLineWeight(), '#000');
18
19
            if ($this->isFilled()) {
20
                $rectangle->background('#000');
21
            }
22 1
        };
23
24 1
        $canvas->rectangle(
25 1
            0,
26 1
            0,
27 1
            $this->getWidth() - $this->getLineWeight(),
28 1
            $this->getHeight() - $this->getLineWeight(),
29
            $rectangleConf
30 1
        );
31
32 1
        return $canvas;
33
    }
34
35
    /**
36
     * Is the box filled, or just an outline?
37
     *
38
     * @var bool
39
     */
40
    abstract protected function isFilled();
41
}
42