Passed
Push — master ( 5379a4...a2888f )
by Joao
04:49
created

FixedTextDefinition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 2 Features 0
Metric Value
c 4
b 2
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 5
crap 2
1
<?php
2
3
namespace ByJG\AnyDataset\Enum;
4
5
/**
6
 * @package xmlnuke
7
 */
8
class FixedTextDefinition
9
{
10
11
    public $fieldName;
12
    public $startPos;
13
    public $length;
14
    public $requiredValue;
15
    public $subTypes = array();
16
17
    /**
18
     *
19
     * @param string $fieldName
20
     * @param int $startPos
21
     * @param int $length
22
     * @param bool|string $requiredValue
23
     * @param FixedTextDefinition[] $subTypes
24
     */
25
    public function __construct($fieldName, $startPos, $length, $requiredValue = "", $subTypes = null)
26
    {
27
        $this->fieldName = $fieldName;
28
        $this->startPos = $startPos;
29
        $this->length = $length;
30
        $this->requiredValue = $requiredValue;
31
        $this->subTypes = $subTypes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $subTypes can be null. However, the property $subTypes is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
32
    }
33
}
34