Total Complexity | 7 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class StringSchema extends AbstractSchema |
||
12 | { |
||
13 | 26 | public function __construct() |
|
14 | { |
||
15 | 26 | parent::__construct( |
|
16 | 26 | new TypeKeyword('string') |
|
17 | ); |
||
18 | 26 | } |
|
19 | |||
20 | /** |
||
21 | * @return static |
||
22 | */ |
||
23 | 1 | public function nullable(bool $nullable = true): self |
|
24 | { |
||
25 | 1 | if (!$nullable) { |
|
26 | 1 | return $this->with( |
|
27 | 1 | new TypeKeyword('string') |
|
28 | ); |
||
29 | } |
||
30 | |||
31 | 1 | return $this->with( |
|
32 | 1 | new TypeKeyword(['string', 'null']) |
|
33 | ); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return static |
||
38 | */ |
||
39 | 1 | public function minLength(?int $minLength): self |
|
43 | ); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return static |
||
48 | */ |
||
49 | 1 | public function maxLength(?int $maxLength): self |
|
50 | { |
||
51 | 1 | return $this->with( |
|
52 | 1 | new MaxLengthKeyword($maxLength) |
|
53 | ); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return static |
||
58 | */ |
||
59 | 1 | public function pattern(?string $pattern): self |
|
63 | ); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return static |
||
68 | */ |
||
69 | 1 | public function format(?string $format): self |
|
76 |