Completed
Push — master ( eb47af...bb59c7 )
by Woody
01:18
created

ArraySchema   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A phpType() 0 8 2
A hasItems() 0 5 2
A items() 0 4 2
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 2
    public function phpType(): string
11
    {
12 2
        if ($this->hasItems()) {
13 2
            return $this->items()->phpType() . '[]';
14
        }
15
16 1
        return 'array';
17
    }
18
19 3
    public function hasItems(): bool
20
    {
21 3
        return isset($this->schema->items)
22 3
            && isset($this->schema->items->type);
23
    }
24
25 3
    public function items(): ?Schema
26
    {
27 3
        return $this->hasItems() ? Schema::make($this->schema->items) : null;
28
    }
29
}
30