Code Duplication    Length = 13-13 lines in 2 locations

src/Exceptions/InvalidIndexException.php 1 location

@@ 7-19 (lines=13) @@
4
5
use InvalidArgumentException;
6
7
class InvalidIndexException extends InvalidArgumentException
8
{
9
    public function __construct($index, string $class)
10
    {
11
        if (is_int($index)) {
12
            $message = sprintf('The given index [%d] is not available in this enum %s', $index, $class);
13
        } else {
14
            $message = sprintf('The index for an enum must be an int but %s given', gettype($index));
15
        }
16
17
        parent::__construct($message);
18
    }
19
}
20

src/Exceptions/InvalidValueException.php 1 location

@@ 7-19 (lines=13) @@
4
5
use InvalidArgumentException;
6
7
class InvalidValueException extends InvalidArgumentException
8
{
9
    public function __construct($value, string $class)
10
    {
11
        if (is_string($value)) {
12
            $message = sprintf('The given value [%s] is not available in this enum %s', $value, $class);
13
        } else {
14
            $message = sprintf('The value for an enum must be a string but %s given', gettype($value));
15
        }
16
17
        parent::__construct($message);
18
    }
19
}
20