Passed
Push — master ( 0e1b55...4f9081 )
by Julien
01:38 queued 10s
created

TypeCheck::andThat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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
24
    /**
25
     * @template T
26
     * @param mixed $sut
27
     * @psalm-param T of mixed
28
     * @psalm-return FluentCheck<T>
29
     * @return BooleanCheck|GenericCheck|CallableCheck|CollectionCheck|ResponseCheck|ArrayCheck|DateTimeCheck|StringCheck|ExceptionCheck|FloatCheck|IntegerCheck
30
     */
31 5
    public function that(): self
32
    {
33 5
        return $this;
34
    }
35
36
    /**
37
     * @template T
38
     * @param mixed $sut
39
     * @psalm-param T of mixed
40
     * @psalm-return FluentCheck<T>
41
     * @return BooleanCheck|GenericCheck|CallableCheck|CollectionCheck|ResponseCheck|ArrayCheck|DateTimeCheck|StringCheck|ExceptionCheck|FloatCheck|IntegerCheck
42
     */
43 2
    public function andThat($sut): FluentCheck
44
    {
45 2
        return Check::that($sut);
46
    }
47
48
49 1
    public function isString(): self
50
    {
51 1
        Assert::assertIsString($this->value, $this->message);
52 1
        return $this;
53
    }
54
55 1
    public function isArray(): self
56
    {
57 1
        Assert::assertIsArray($this->value, $this->message);
58 1
        return $this;
59
    }
60
61 1
    public function isBool(): self
62
    {
63 1
        Assert::assertIsBool($this->value, $this->message);
64 1
        return $this;
65
    }
66
67 1
    public function isFloat(): self
68
    {
69 1
        Assert::assertIsFloat($this->value, $this->message);
70 1
        return $this;
71
    }
72
73 1
    public function isInt(): self
74
    {
75 1
        Assert::assertIsInt($this->value, $this->message);
76 1
        return $this;
77
    }
78
79 1
    public function isNumeric(): self
80
    {
81 1
        Assert::assertIsNumeric($this->value, $this->message);
82 1
        return $this;
83
    }
84
85 1
    public function isObject(): self
86
    {
87 1
        Assert::assertIsObject($this->value, $this->message);
88 1
        return $this;
89
    }
90
91 1
    public function isResource(): self
92
    {
93 1
        Assert::assertIsResource($this->value, $this->message);
94 1
        return $this;
95
    }
96
97 1
    public function isScalar(): self
98
    {
99 1
        Assert::assertIsScalar($this->value, $this->message);
100 1
        return $this;
101
    }
102
103 1
    public function isCallable(): self
104
    {
105 1
        Assert::assertIsCallable($this->value, $this->message);
106 1
        return $this;
107
    }
108
109 1
    public function isIterable(): self
110
    {
111 1
        Assert::assertIsIterable($this->value, $this->message);
112 1
        return $this;
113
    }
114
115
    /**
116
     * @param string $expected
117
     * @psalm-param class-string $expected
118
     *
119
     * @return self
120
     */
121 76
    public function isAnInstanceOf(string $expected): self
122
    {
123 76
        Assert::assertInstanceOf($expected, $this->value, $this->message);
124 76
        return $this;
125
    }
126
}
127