Test Failed
Push — main ( 5af89f...c76fcf )
by Bingo
05:51
created

Direction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Jabe\Engine\Impl;
4
5
class Direction
6
{
7
    private static $ASCENDING;
8
    private static $DESCENDING;
9
10
    private $name;
11
12
    public function __construct(string $name)
13
    {
14
        $this->name = $name;
15
    }
16
17
    public static function ascending(): Direction
18
    {
19
        if (self::$ASCENDING == null) {
20
            self::$ASCENDING = new Direction("asc");
21
        }
22
        return self::$ASCENDING;
23
    }
24
25
    public function descending(): Direction
26
    {
27
        if (self::$DESCENDING == null) {
28
            self::$DESCENDING = new Direction("desc");
29
        }
30
        return self::$DESCENDING;
31
    }
32
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    public function __toString()
39
    {
40
        return "Direction["
41
            . "name=" . $this->name
42
            . "]";
43
    }
44
45
    public static function findByName(string $directionName): ?Direction
46
    {
47
        switch ($directionName) {
48
            case "asc":
49
                return self::ascending();
50
            case "desc":
51
                return self::descending();
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Direction::descending() is not static, but was called statically. ( Ignorable by Annotation )

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

51
                return self::/** @scrutinizer ignore-call */ descending();
Loading history...
52
            default:
53
                return null;
54
        }
55
    }
56
}
57