TypeArray::cast()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mvkasatkin\typecast\type;
4
5
class TypeArray extends Type
6
{
7
8
    /**
9
     * @param array $default
10
     */
11
    public function __construct($default = [])
12
    {
13
        parent::__construct($default);
14
    }
15
16
    /**
17
     * @param $value
18
     *
19
     * @return array|null
20
     */
21
    public function cast($value)
22
    {
23
        return $value === null ? $this->default : (array)$value;
24
    }
25
}
26