jaxon-php /
jaxon-mono
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Ticks.php - Contains data to be printed on the plot axis. |
||
| 5 | * |
||
| 6 | * @package jaxon-flot |
||
| 7 | * @author Thierry Feuzeu <[email protected]> |
||
| 8 | * @copyright 2017 Thierry Feuzeu <[email protected]> |
||
| 9 | * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
||
| 10 | * @link https://github.com/jaxon-php/jaxon-flot |
||
| 11 | */ |
||
| 12 | |||
| 13 | namespace Jaxon\Flot\Data; |
||
| 14 | |||
| 15 | use JsonSerializable; |
||
| 16 | use stdClass; |
||
| 17 | |||
| 18 | use function count; |
||
| 19 | |||
| 20 | class Ticks implements JsonSerializable |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The points |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $aPoints; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The points labels |
||
| 32 | * |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | protected $aLabels; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * The constructor. |
||
| 39 | */ |
||
| 40 | public function __construct() |
||
| 41 | { |
||
| 42 | $this->aPoints = []; |
||
| 43 | $this->aLabels = ['data' => null, 'func' => null]; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Add a point to the ticks. |
||
| 48 | * |
||
| 49 | * @param integer $iXaxis The point on the X axis |
||
| 50 | * @param string $sLabel The value on the graph |
||
| 51 | * |
||
| 52 | * @return static |
||
| 53 | */ |
||
| 54 | public function point($iXaxis, $sLabel): static |
||
| 55 | { |
||
| 56 | $this->aPoints[] = $iXaxis; |
||
| 57 | if(!$this->aLabels['data']) |
||
| 58 | { |
||
| 59 | $this->aLabels['data'] = []; |
||
| 60 | } |
||
| 61 | $this->aLabels['data']["$iXaxis"] = $sLabel; |
||
| 62 | return $this; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Add an array of points to the ticks. |
||
| 67 | * |
||
| 68 | * @param array $aPoints The points to be added |
||
| 69 | * |
||
| 70 | * @return int |
||
| 71 | */ |
||
| 72 | public function points($aPoints): int |
||
| 73 | { |
||
| 74 | foreach($aPoints as $aPoint) |
||
| 75 | { |
||
| 76 | if(count($aPoint) == 2) |
||
| 77 | { |
||
| 78 | $this->point($aPoint[0], $aPoint[1]); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | return count($this->aPoints); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Add points to the ticks using an expression. |
||
| 86 | * |
||
| 87 | * @param numeric $iStart The first point |
||
| 88 | * @param numeric $iEnd The last point |
||
|
0 ignored issues
–
show
|
|||
| 89 | * @param numeric $iStep The step between next points |
||
| 90 | * @param string $sJsLabel The javascript code to make points labels |
||
| 91 | * |
||
| 92 | * The first three parameters are used in a for loop. |
||
| 93 | * The x variable is used in the javascript code to represent each point. |
||
| 94 | * |
||
| 95 | * @return int |
||
| 96 | */ |
||
| 97 | public function expr($iStart, $iEnd, $iStep, $sJsLabel): int |
||
| 98 | { |
||
| 99 | for($x = $iStart; $x < $iEnd; $x += $iStep) |
||
| 100 | { |
||
| 101 | $this->aPoints[] = $x; |
||
| 102 | } |
||
| 103 | if(($sJsLabel)) |
||
| 104 | { |
||
| 105 | $this->aLabels['func'] = $sJsLabel; |
||
| 106 | } |
||
| 107 | return count($this->aPoints); |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Convert this object to another object more suitable for json format. |
||
| 112 | * |
||
| 113 | * This is a method of the JsonSerializable interface. |
||
| 114 | * |
||
| 115 | * @return stdClass |
||
| 116 | */ |
||
| 117 | public function jsonSerialize(): stdClass |
||
| 118 | { |
||
| 119 | // Surround the js var with a special marker that will later be removed |
||
| 120 | // Note: does not work when returning an array |
||
| 121 | $json = new stdClass; |
||
| 122 | $json->points = $this->aPoints; |
||
| 123 | $json->labels = $this->aLabels; |
||
| 124 | return $json; |
||
| 125 | } |
||
| 126 | } |
||
| 127 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths