Passed
Push — master ( b2203e...6c080a )
by Julien
03:10
created

IntegerCheck::asDateTime()   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;
5
6
use PHPUnit\Framework\Assert;
7
use Pitchart\Phlunit\Checks\Converter\ToDateTime;
8
use Pitchart\Phlunit\Checks\Mixin\ConstraintCheck;
9
use Pitchart\Phlunit\Checks\Mixin\TypeCheck;
10
use Pitchart\Phlunit\Checks\Mixin\WithMessage;
11
12
/**
13
 * Class IntegerCheck
14
 *
15
 * @package Pitchart\Phlunit\Checks
16
 *
17
 * @author Julien VITTE <[email protected]>
18
 *
19
 * @implements FluentCheck<int>
20
 */
21
class IntegerCheck implements FluentCheck
22
{
23 1
    use TypeCheck, ConstraintCheck, WithMessage;
24 1
    use ToDateTime { asDateTime as asDateTimeWithFormat; }
25
26
    /**
27
     * @var int
28
     */
29
    private $value;
30
31
    /**
32
     * GenericCheck constructor.
33
     *
34
     * @param $value
35
     */
36 11
    public function __construct(int $value)
37
    {
38 11
        $this->value = $value;
39 11
    }
40
41 1
    public function isEqualTo(int $expected): self
42
    {
43 1
        Assert::assertSame($expected, $this->value, $this->message);
44 1
        $this->resetMessage();
45 1
        return $this;
46
    }
47
48 1
    public function isNotEqualTo(int $expected): self
49
    {
50 1
        Assert::assertNotSame($expected, $this->value, $this->message);
51 1
        $this->resetMessage();
52 1
        return $this;
53
    }
54
55 1
    public function isEmpty(): self
56
    {
57 1
        Assert::assertEmpty($this->value, $this->message);
58 1
        $this->resetMessage();
59 1
        return $this;
60
    }
61
62 1
    public function isNotEmpty(): self
63
    {
64 1
        Assert::assertNotEmpty($this->value, $this->message);
65 1
        $this->resetMessage();
66 1
        return $this;
67
    }
68
69 2
    public function isGreaterThan(float $expected): self
70
    {
71 2
        Assert::assertGreaterThan($expected, $this->value, $this->message);
72 2
        $this->resetMessage();
73 2
        return $this;
74
    }
75
76 1
    public function isGreaterThanOrEqualTo(float $expected): self
77
    {
78 1
        Assert::assertGreaterThanOrEqual($expected, $this->value, $this->message);
79 1
        $this->resetMessage();
80 1
        return $this;
81
    }
82
83 2
    public function isLessThan(float $expected): self
84
    {
85 2
        Assert::assertLessThan($expected, $this->value, $this->message);
86 2
        $this->resetMessage();
87 2
        return $this;
88
    }
89
90 1
    public function isLessThanOrEqualTo(float $expected): self
91
    {
92 1
        Assert::assertLessThanOrEqual($expected, $this->value, $this->message);
93 1
        $this->resetMessage();
94 1
        return $this;
95
    }
96
97 1
    public function asDateTime(string $format = 'Y-m-d H:i:s'): DateTimeCheck
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

97
    public function asDateTime(/** @scrutinizer ignore-unused */ string $format = 'Y-m-d H:i:s'): DateTimeCheck

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
98
    {
99 1
        return $this->asDateTimeWithFormat('U');
100
    }
101
102
103
}
104