| Conditions | 5 |
| Paths | 16 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function render($flags = null) |
||
| 22 | { |
||
| 23 | $config = [ |
||
| 24 | 'type' => constant(get_class($this->chart) . "::TYPE"), |
||
| 25 | 'data' => [], |
||
| 26 | ]; |
||
| 27 | |||
| 28 | $labels = $this->chart->labels()->jsonSerialize(); |
||
| 29 | if ($labels) { |
||
|
|
|||
| 30 | $config['data']['labels'] = $labels; |
||
| 31 | } |
||
| 32 | |||
| 33 | $dataSets = $this->chart->dataSets()->jsonSerialize(); |
||
| 34 | if ($dataSets) { |
||
| 35 | $config['data']['datasets'] = $dataSets; |
||
| 36 | } |
||
| 37 | |||
| 38 | $options = $this->chart->options()->jsonSerialize(); |
||
| 39 | if (! empty($options)) { |
||
| 40 | $config['options'] = $options; |
||
| 41 | } |
||
| 42 | |||
| 43 | $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); |
||
| 44 | if ($flags & Renderer::RENDER_PRETTY) { |
||
| 45 | $output = JsonHelper::prettyPrint($output); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $output; |
||
| 49 | } |
||
| 51 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.