Enum   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromNative() 0 8 2
A toNative() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\System;
13
14
use Cubiche\Core\Enum\Enum as BaseEnum;
15
use Cubiche\Domain\Model\NativeValueObjectInterface;
16
17
/**
18
 * Enum Class.
19
 *
20
 * @author Karel Osorio Ramírez <[email protected]>
21
 */
22
abstract class Enum extends BaseEnum implements NativeValueObjectInterface
23
{
24
    /**
25
     * @param mixed $value
26
     *
27
     * @return \Cubiche\Domain\System\Enum
28
     */
29
    public static function fromNative($value)
30
    {
31
        try {
32
            return new static($value);
33
        } catch (\UnexpectedValueException $e) {
34
            throw new \InvalidArgumentException($e->getMessage(), $e->getCode());
35
        }
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function toNative()
42
    {
43
        return $this->value();
44
    }
45
}
46