Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.016 |
Changes | 0 |
1 | <?php |
||
26 | 49 | public static function build(Str $schema, Properties $properties): Property |
|
27 | { |
||
28 | 49 | if (!$schema->matches(self::PATTERN)) { |
|
29 | throw new SchemaNotParseable((string) $schema); |
||
30 | } |
||
31 | |||
32 | 49 | $type = (string) $schema->capture(self::PATTERN)->get('type'); |
|
33 | |||
34 | 49 | if (!function_exists('is_'.$type)) { |
|
35 | 8 | throw new SchemaNotParseable((string) $schema); |
|
36 | } |
||
37 | |||
38 | 43 | $self = new self($type); |
|
39 | |||
40 | 43 | if ((string) $schema->substring(0, 1) === '?') { |
|
41 | 14 | $self->optional = true; |
|
42 | } |
||
43 | |||
44 | 43 | return $self; |
|
45 | } |
||
63 |