Code Duplication    Length = 13-13 lines in 3 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
        $message = 'The index for an enum must be an int but '.gettype($index).' given';
12
13
        if (is_int($index)) {
14
            $message = 'The given index ['.$index.'] is not available in this enum '.$class;
15
        }
16
17
        parent::__construct($message);
18
    }
19
}
20

src/Exceptions/InvalidNameException.php 1 location

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