Completed
Push — master ( 9bb71b...eb47af )
by Woody
01:27
created

ArraySchema   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

3 Methods

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