This method 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...
34
{
35
switch ($toType) {
36
3
case Type::INT:
37
1
return $this->value;
38
3
case Type::FLOAT:
39
1
return (float) $this->get();
40
3
case Type::STRING:
41
1
return (string) $this->get();
42
default:
43
2
throw new InvalidTypeCastException(static::class, $this->getTranslatedType($toType));
44
}
45
}
46
47
/**
48
* {@inheritdoc}
49
*
50
* @return IntType
51
*/
52
27
public static function valueOf($mixed, int $precision = null): IntType
53
{
54
//Dealing with big integers. Best to use FloatType.
55
27
if (is_numeric($mixed) && ($mixed >= PHP_INT_MAX && !ctype_digit($mixed))) {
56
1
throw new \RuntimeException('Incorrect type used. Use FloatType instead.');
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.