Passed
Push — main ( e16d46...16e3d2 )
by Damien
07:21
created

InlineNode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 17
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addMark() 0 3 1
A jsonSerialize() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Adf\Node;
6
7
abstract class InlineNode extends Node
8
{
9
    private array $marks = [];
10
11
    public function jsonSerialize(): array
12
    {
13
        $result = parent::jsonSerialize();
14
        if ($this->marks) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->marks of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
15
            $result['marks'] = $this->marks;
16
        }
17
18
        return $result;
19
    }
20
21
    protected function addMark(MarkNode $mark): void
22
    {
23
        $this->marks[] = $mark;
24
    }
25
}
26