ReadDirection::isForward()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace RayRutjes\GetEventStore;
4
5
class ReadDirection
6
{
7
    const FORWARD = 1;
8
    const BACKWARD = 0;
9
10
    /**
11
     * @var int
12
     */
13
    private $value;
14
15
    /**
16
     * @param int $value
17
     */
18 View Code Duplication
    public function __construct(int $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        if ($value !== self::FORWARD && $value !== self::BACKWARD) {
21
            throw new \InvalidArgumentException('Invalid direction.');
22
        }
23
24
        $this->value = $value;
25
    }
26
27
    /**
28
     * @return bool
29
     */
30
    public function isForward(): bool
31
    {
32
        return $this->value === self::FORWARD;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isBackward(): bool
39
    {
40
        return $this->value === self::BACKWARD;
41
    }
42
}
43