ImageShape   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 34
ccs 0
cts 15
cp 0
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A color() 0 5 1
A setImage() 0 5 1
A createColor() 0 7 1
A drawLine() 0 5 1
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