LinkArrow::Stroke()   B
last analyzed

Complexity

Conditions 7
Paths 1

Size

Total Lines 45
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
cc 7
eloc 32
nc 1
nop 1
dl 0
loc 45
ccs 0
cts 35
cp 0
crap 56
rs 8.4746
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Image;
8
9
use Amenadiel\JpGraph\Util;
10
11
/**
12
 * @class LinkArrow
13
 * // Handles the drawing of a an arrow
14
 */
15
class LinkArrow
16
{
17
    private $ix;
18
    private $iy;
19
    private $isizespec = [
20
        [2, 3], [3, 5], [3, 8], [6, 15], [8, 22], ];
21
    private $iDirection = ARROW_DOWN;
22
    private $iType      = ARROWT_SOLID;
23
    private $iSize      = ARROW_S2;
24
    private $iColor     = 'black';
25
26
    public function __construct($x, $y, $aDirection, $aType = ARROWT_SOLID, $aSize = ARROW_S2)
27
    {
28
        $this->iDirection = $aDirection;
29
        $this->iType      = $aType;
30
        $this->iSize      = $aSize;
31
        $this->ix         = $x;
32
        $this->iy         = $y;
33
    }
34
35
    public function SetColor($aColor)
36
    {
37
        $this->iColor = $aColor;
38
    }
39
40
    public function SetSize($aSize)
41
    {
42
        $this->iSize = $aSize;
43
    }
44
45
    public function SetType($aType)
46
    {
47
        $this->iType = $aType;
48
    }
49
50
    public function Stroke($aImg)
51
    {
52
        list($dx, $dy) = $this->isizespec[$this->iSize];
53
        $x             = $this->ix;
54
        $y             = $this->iy;
55
        switch ($this->iDirection) {
56
            case ARROW_DOWN:
57
                $c = [$x, $y, $x - $dx, $y - $dy, $x + $dx, $y - $dy, $x, $y];
58
59
                break;
60
            case ARROW_UP:
61
                $c = [$x, $y, $x - $dx, $y + $dy, $x + $dx, $y + $dy, $x, $y];
62
63
                break;
64
            case ARROW_LEFT:
65
                $c = [$x, $y, $x + $dy, $y - $dx, $x + $dy, $y + $dx, $x, $y];
66
67
                break;
68
            case ARROW_RIGHT:
69
                $c = [$x, $y, $x - $dy, $y - $dx, $x - $dy, $y + $dx, $x, $y];
70
71
                break;
72
            default:
73
                Util\JpGraphError::RaiseL(6030);
74
                //('Unknown arrow direction for link.');
75
                die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
76
77
                break;
78
        }
79
        $aImg->SetColor($this->iColor);
80
        switch ($this->iType) {
81
            case ARROWT_SOLID:
82
                $aImg->FilledPolygon($c);
83
84
                break;
85
            case ARROWT_OPEN:
86
                $aImg->Polygon($c);
87
88
                break;
89
            default:
90
                Util\JpGraphError::RaiseL(6031);
91
                //('Unknown arrow type for link.');
92
                die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
93
94
                break;
95
        }
96
    }
97
}
98