ImageShape::drawLine()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Suricate;
6
7
class ImageShape
8
{
9
    private $image;
10
    private $color = [0, 0, 0];
11
12
    public function setImage(&$image)
13
    {
14
        $this->image = $image;
15
16
        return $this;
17
    }
18
19
    public function color($color)
20
    {
21
        $this->color = $color;
22
23
        return $this;
24
    }
25
26
    public function createColor()
27
    {
28
        return imagecolorallocate(
29
            $this->image,
30
            $this->color[0],
31
            $this->color[1],
32
            $this->color[2]
33
        );
34
    }
35
36
    public function drawLine($x1, $y1, $x2, $y2)
37
    {
38
        imageline($this->image, $x1, $y1, $x2, $y2, $this->createColor());
39
40
        return $this;
41
    }
42
}
43