Completed
Pull Request — master (#18)
by Tom
01:50 queued 31s
created

InvalidIndexException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Spatie\Enum\Exceptions;
4
5
use InvalidArgumentException;
6
7 View Code Duplication
class InvalidIndexException extends InvalidArgumentException
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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