Passed
Pull Request — master (#30)
by John
02:53
created

AbstractBoxRenderer::render()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 9.9332
c 0
b 0
f 0
cc 2
nc 1
nop 0
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
    public function render()
13
    {
14
        $canvas = $this->getImageManager()->canvas($this->getWidth(), $this->getHeight(), $this->getTracerColour());
15
16
        $rectangleConf = function ($rectangle) {
17
            $rectangle->border($this->getLineWeight(), '#000');
18
19
            if ($this->isFilled()) {
20
                $rectangle->background('#000');
21
            }
22
        };
23
24
        $canvas->rectangle(
25
            0,
26
            0,
27
            $this->getWidth() - $this->getLineWeight(),
28
            $this->getHeight() - $this->getLineWeight(),
29
            $rectangleConf
30
        );
31
32
        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