Total Complexity | 8 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 73.32% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class ImgData |
||
17 | { |
||
18 | protected $name = ''; // Each subclass gives a name |
||
19 | protected $an = []; // Data array names |
||
20 | protected $colors = []; // Available colors |
||
21 | protected $index = []; // Index for colors |
||
22 | protected $maxidx = 0; // Max color index |
||
23 | protected $anchor_x = 0.5; |
||
24 | protected $anchor_y = 0.5; // Where is the center of the image |
||
25 | |||
26 | public function __construct() |
||
27 | { |
||
28 | // Empty |
||
29 | } |
||
30 | |||
31 | // Create a GD image from the data and return a GD handle |
||
32 | 3 | public function GetImg($aMark, $aIdx) |
|
33 | { |
||
34 | 3 | $n = $this->an[$aMark]; |
|
35 | 3 | if (is_string($aIdx)) { |
|
36 | 3 | if (!in_array($aIdx, $this->colors, true)) { |
|
37 | Util\JpGraphError::RaiseL(23001, $this->name, $aIdx); //('This marker "'.($this->name).'" does not exist in color: '.$aIdx); |
||
38 | } |
||
39 | 3 | $idx = $this->index[$aIdx]; |
|
40 | 1 | } elseif (!is_integer($aIdx) || |
|
41 | 1 | (is_integer($aIdx) && $aIdx > $this->maxidx)) { |
|
42 | Util\JpGraphError::RaiseL(23002, $this->name); //('Mark color index too large for marker "'.($this->name).'"'); |
||
43 | } else { |
||
44 | 1 | $idx = $aIdx; |
|
45 | } |
||
46 | |||
47 | 3 | return Image::CreateFromString(base64_decode($this->{$n}[$idx][1], true)); |
|
|
|||
48 | } |
||
49 | |||
50 | 3 | public function GetAnchor() |
|
53 | } |
||
54 | } |
||
55 |