Code Duplication    Length = 6-6 lines in 2 locations

src/EnumSerializableTrait.php 1 location

@@ 51-56 (lines=6) @@
48
        $value     = \unserialize($serialized);
49
        $constants = self::getConstants();
50
        $name      = \array_search($value, $constants, true);
51
        if ($name === false) {
52
            $message = \is_scalar($value)
53
                ? 'Unknown value ' . \var_export($value, true)
54
                : 'Invalid value of type ' . (\is_object($value) ? \get_class($value) : \gettype($value));
55
            throw new RuntimeException($message);
56
        }
57
58
        $class      = \get_class($this);
59
        $enumerator = $this;

src/Enum.php 1 location

@@ 194-199 (lines=6) @@
191
    {
192
        $constants = self::detectConstants(static::class);
193
        $name      = \array_search($value, $constants, true);
194
        if ($name === false) {
195
            $message = \is_scalar($value)
196
                ? 'Unknown value ' . \var_export($value, true)
197
                : 'Invalid value of type ' . (\is_object($value) ? \get_class($value) : \gettype($value));
198
            throw new InvalidArgumentException($message);
199
        }
200
201
        if (!isset(self::$instances[static::class][$name])) {
202
            self::$instances[static::class][$name] = new static($constants[$name]);