Enum::getInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
namespace Robusto\Enum;
3
4
/**
5
 * Abstract class for enumerations.
6
 *
7
 * @author Jarddel Antunes
8
 * @package Robusto\Enum
9
 * @copyright 2017 Robusto Enum
10
 */
11
abstract class Enum implements EnumInterface
12
{
13
    use EnumTrait;
14
15
    /**
16
     *
17
     * @param int $value
18
     */
19
    final private function __construct(int $value, string $description = null)
20
    {
21
        $this->value = $value;
22
        $this->description = $description;
23
    }
24
25
    /**
26
     * Get the instance of the enumerative class
27
     *
28
     * @return EnumInterface
29
     */
30
    protected static function getInstance(int $value, string $description = null): EnumInterface
31
    {
32
        return new static($value, $description);
33
    }
34
}
35