ReadDirection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 21.05 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 8
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 3
A isForward() 0 4 1
A isBackward() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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