Completed
Pull Request — master (#18)
by Tom
01:30
created

InvalidValueException::__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 InvalidValueException 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($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