Completed
Push — master ( 9d6b90...0a141c )
by Randy
11:08
created

ScalarExpectations::isIdenticalTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dgame\Expectation;
4
5
/**
6
 * Class ScalarExpectations
7
 * @package Dgame\Expectation
8
 */
9
class ScalarExpectations
10
{
11
    use ConditionTrait;
12
13
    /**
14
     * ScalarExpectations constructor.
15
     *
16
     * @param $value
17
     */
18
    public function __construct($value)
19
    {
20
        if ($this->approveIf(is_scalar($value))->isApproved()) {
21
            $this->value = $this->prepare($value);
22
        }
23
    }
24
25
    /**
26
     * @param $value
27
     *
28
     * @return mixed
29
     */
30
    protected function prepare($value)
31
    {
32
        return $value;
33
    }
34
35
    /**
36
     * @return ScalarExpectations
37
     */
38
    final public function isEmpty(): self
39
    {
40
        return $this->approveIf(empty($this->value));
41
    }
42
43
    /**
44
     * @return ScalarExpectations
45
     */
46
    final public function isNotEmpty(): self
47
    {
48
        return $this->approveIf(!empty($this->value));
49
    }
50
51
    /**
52
     * @param $value
53
     *
54
     * @return ScalarExpectations
55
     */
56
    final public function isEqual($value): self
57
    {
58
        return $this->approveIf($this->value == $value);
59
    }
60
61
    /**
62
     * @param $value
63
     *
64
     * @return ScalarExpectations
65
     */
66
    final public function isNotEqual($value): self
67
    {
68
        return $this->approveIf($this->value != $value);
69
    }
70
71
    /**
72
     * @param $value
73
     *
74
     * @return ScalarExpectations
75
     */
76
    final public function isIdenticalTo($value): self
77
    {
78
        return $this->approveIf($this->value === $value);
79
    }
80
81
    /**
82
     * @param $value
83
     *
84
     * @return ScalarExpectations
85
     */
86
    final public function isNotIdenticalTo($value): self
87
    {
88
        return $this->approveIf($this->value !== $value);
89
    }
90
}