ArrayType::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
/**
4
 * This file is part of the sj-i/phpdoc-type-reader package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpDocTypeReader\Type;
15
16
class ArrayType extends AtomicType
17
{
18
    /** @var Type[] */
19
    public array $parameter_types;
20
21
    public ArrayKeyType $key_type;
22
23
    public Type $value_type;
24
25
    public function __construct(Type $value_type, ?ArrayKeyType $key_type = null)
26
    {
27
        if (is_null($key_type)) {
28
            $key_type = new ArrayKeyType();
29
        }
30
        $this->key_type = $key_type;
31
        $this->value_type = $value_type;
32
        $this->parameter_types = [$value_type, $key_type];
33
    }
34
}
35