Completed
Push — master ( bb59c7...b639e0 )
by Woody
01:20
created

ArraySchema::phpType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace RoundingWell\Schematic\Schema;
5
6
use RoundingWell\Schematic\Schema;
7
8
class ArraySchema extends Schema
9
{
10
    public function phpType(): string
11
    {
12
        if ($this->hasItems()) {
13
            return $this->items()->phpType() . '[]';
14
        }
15
16
        return 'array';
17
    }
18
19
    public function hasItems(): bool
20
    {
21
        return isset($this->schema->items)
22
            && isset($this->schema->items->type);
23
    }
24
25
    public function items(): ?Schema
26
    {
27
        return $this->hasItems() ? Schema::make($this->schema->items) : null;
28
    }
29
}
30