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...
35
{
36
17
$direction = strtolower($direction);
37
17
if (!preg_match('/\A(forward|backward)\z/', $direction, $m)) {
38
throw new BadKeywordException('Direction must be "forward" or "backward"');
39
}
40
17
return $m[1];
41
}
42
43
/**
44
* @return string
45
*/
46
10
public function __toString()
47
{
48
10
return $this->direction;
49
}
50
51
/**
52
* @return bool
53
*/
54
2
public function forward()
55
{
56
2
return $this->direction === static::FORWARD;
57
}
58
59
/**
60
* @return bool
61
*/
62
17
public function backward()
63
{
64
17
return $this->direction === static::BACKWARD;
65
}
66
67
/**
68
* @return static
69
*/
70
public function inverse()
71
{
72
return new static($this->direction === static::FORWARD ? static::BACKWARD : static::FORWARD);
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.