Completed
Push — master ( 505914...3d6e9d )
by Ivannis Suárez
03:13
created

Enum.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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();
0 ignored issues
show
The method value() does not exist on Cubiche\Domain\System\Enum. Did you maybe mean values()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
44
    }
45
}
46