Completed
Pull Request — master (#2)
by Joao
05:22
created

FixedTextDefinition   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
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 2
    public function __construct($fieldName, $startPos, $length, $requiredValue = "", $subTypes = null)
26
    {
27 2
        $this->fieldName = $fieldName;
28 2
        $this->startPos = $startPos;
29 2
        $this->length = $length;
30 2
        $this->requiredValue = $requiredValue;
31 2
        $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 2
    }
33
}
34