Completed
Pull Request — master (#1)
by Ondrej
01:51
created

VotingDecisionEnum::DENIED()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace SpareParts\Overseer;
3
4
5 View Code Duplication
final class VotingDecisionEnum
0 ignored issues
show
Duplication introduced by
This class 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...
6
{
7
    /**
8
     * @var string
9
     */
10
    private $value;
11
12
    /**
13
     * @var self[]
14
     */
15
    static private $registry = [];
16
17
    private function __construct($value)
18
    {
19
        $this->value = $value;
20
    }
21
22
23
    /**
24
     * @return self
25
     */
26
    public static function ALLOWED()
27
    {
28
        return static::instance('allowed');
0 ignored issues
show
Comprehensibility introduced by
Since SpareParts\Overseer\VotingDecisionEnum is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
29
    }
30
31
32
    /**
33
     * @return self
34
     */
35
    public static function DENIED()
36
    {
37
        return static::instance('allowed');
0 ignored issues
show
Comprehensibility introduced by
Since SpareParts\Overseer\VotingDecisionEnum is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
38
    }
39
40
41
    /**
42
     * @param $string
43
     * @return self
44
     */
45
    private static function instance($string)
46
    {
47
        if (!isset(static::$registry[$string])) {
0 ignored issues
show
Comprehensibility introduced by
Since SpareParts\Overseer\VotingDecisionEnum is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
48
            static::$registry[$string] = new static($string);
0 ignored issues
show
Comprehensibility introduced by
Since SpareParts\Overseer\VotingDecisionEnum is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
49
        }
50
        return static::$registry[$string];
0 ignored issues
show
Comprehensibility introduced by
Since SpareParts\Overseer\VotingDecisionEnum is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
51
    }
52
53
54
    /**
55
     * @return string
56
     */
57
    public function __toString()
58
    {
59
        return $this->value;
60
    }
61
}