1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Pitchart\Phlunit\Checks\Mixin; |
5
|
|
|
|
6
|
|
|
use PHPUnit\Framework\Assert; |
7
|
|
|
use Pitchart\Phlunit\Check; |
8
|
|
|
use Pitchart\Phlunit\Checks\ArrayCheck; |
9
|
|
|
use Pitchart\Phlunit\Checks\BooleanCheck; |
10
|
|
|
use Pitchart\Phlunit\Checks\CallableCheck; |
11
|
|
|
use Pitchart\Phlunit\Checks\CollectionCheck; |
12
|
|
|
use Pitchart\Phlunit\Checks\DateTimeCheck; |
13
|
|
|
use Pitchart\Phlunit\Checks\ExceptionCheck; |
14
|
|
|
use Pitchart\Phlunit\Checks\FloatCheck; |
15
|
|
|
use Pitchart\Phlunit\Checks\FluentCheck; |
16
|
|
|
use Pitchart\Phlunit\Checks\GenericCheck; |
17
|
|
|
use Pitchart\Phlunit\Checks\IntegerCheck; |
18
|
|
|
use Pitchart\Phlunit\Checks\ResponseCheck; |
19
|
|
|
use Pitchart\Phlunit\Checks\StringCheck; |
20
|
|
|
|
21
|
|
|
trait TypeCheck |
22
|
|
|
{ |
23
|
1 |
|
public function isString(): self |
24
|
|
|
{ |
25
|
1 |
|
Assert::assertIsString($this->value, $this->message); |
26
|
1 |
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
1 |
|
public function isArray(): self |
30
|
|
|
{ |
31
|
1 |
|
Assert::assertIsArray($this->value, $this->message); |
32
|
1 |
|
return $this; |
33
|
|
|
} |
34
|
|
|
|
35
|
1 |
|
public function isBool(): self |
36
|
|
|
{ |
37
|
1 |
|
Assert::assertIsBool($this->value, $this->message); |
38
|
1 |
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
1 |
|
public function isFloat(): self |
42
|
|
|
{ |
43
|
1 |
|
Assert::assertIsFloat($this->value, $this->message); |
44
|
1 |
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
public function isInt(): self |
48
|
|
|
{ |
49
|
1 |
|
Assert::assertIsInt($this->value, $this->message); |
50
|
1 |
|
return $this; |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
public function isNumeric(): self |
54
|
|
|
{ |
55
|
1 |
|
Assert::assertIsNumeric($this->value, $this->message); |
56
|
1 |
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
public function isObject(): self |
60
|
|
|
{ |
61
|
1 |
|
Assert::assertIsObject($this->value, $this->message); |
62
|
1 |
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
1 |
|
public function isResource(): self |
66
|
|
|
{ |
67
|
1 |
|
Assert::assertIsResource($this->value, $this->message); |
68
|
1 |
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
public function isScalar(): self |
72
|
|
|
{ |
73
|
1 |
|
Assert::assertIsScalar($this->value, $this->message); |
74
|
1 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
1 |
|
public function isCallable(): self |
78
|
|
|
{ |
79
|
1 |
|
Assert::assertIsCallable($this->value, $this->message); |
80
|
1 |
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
public function isIterable(): self |
84
|
|
|
{ |
85
|
1 |
|
Assert::assertIsIterable($this->value, $this->message); |
86
|
1 |
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $expected |
91
|
|
|
* @psalm-param class-string $expected |
92
|
|
|
* |
93
|
|
|
* @return self |
94
|
|
|
*/ |
95
|
122 |
|
public function isAnInstanceOf(string $expected): self |
96
|
|
|
{ |
97
|
122 |
|
Assert::assertInstanceOf($expected, $this->value, $this->message); |
98
|
122 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|