Total Complexity | 3 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
12 | trait TypeHandlingTrait |
||
13 | { |
||
14 | /** |
||
15 | * Define the next step via a callback that returns an array or Traversable object. |
||
16 | * |
||
17 | * @param callable $callback |
||
18 | * @param mixed ...$args |
||
19 | * @return static |
||
20 | */ |
||
21 | abstract public function then(callable $callback, ...$args); |
||
22 | |||
23 | |||
24 | /** |
||
25 | * Validate that a value has a specific type. |
||
26 | * @deprecated |
||
27 | * |
||
28 | * @param string|string[] $type |
||
29 | * @param string|\Throwable|null $error |
||
30 | * @return static |
||
31 | */ |
||
32 | 4 | public function expectType($type, $error = null) |
|
|
|||
33 | { |
||
34 | 4 | return $this->then("Improved\iterable_expect_type", $type, $error); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Validate that a value has a specific type. |
||
39 | * |
||
40 | * @param string|string[] $type |
||
41 | * @param \Throwable|null $throwable |
||
42 | * @return static |
||
43 | */ |
||
44 | 3 | public function typeCheck($type, ?\Throwable $throwable = null) |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Cast a value to the specific type or throw an error. |
||
51 | * |
||
52 | * @param string $type |
||
53 | * @param \Throwable|null $throwable |
||
54 | * @return static |
||
55 | */ |
||
56 | 3 | public function typeCast(string $type, ?\Throwable $throwable = null) |
|
61 |