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

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