InvalidArgument   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 10
c 1
b 0
f 0
dl 0
loc 34
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidNumeric() 0 3 1
A unserializableValue() 0 3 1
A invalidBooleanValue() 0 3 1
A isEmpty() 0 3 1
A __construct() 0 6 1
A invalidObject() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\PHPEnv\Exceptions;
6
7
final class InvalidArgument extends Exception
8
{
9
    private function __construct(string $message = "", int $code = 0, \Throwable $previous = null)
10
    {
11
        parent::__construct(
12
            $message,
13
            $code,
14
            $previous
15
        );
16
    }
17
18
    public static function invalidBooleanValue($value): self
19
    {
20
        return new static(var_export($value, true) . ' is not boolish');
21
    }
22
23
    public static function isEmpty(): self
24
    {
25
        return new static('Value cannot be empty');
26
    }
27
28
    public static function invalidNumeric($value): self
29
    {
30
        return new static(var_export($value, true) . ' is not numeric');
31
    }
32
33
    public static function invalidObject($value): self
34
    {
35
        return new static(var_export($value, true) . ' is an valid object');
36
    }
37
38
    public static function unserializableValue($value, \Throwable $previous = null): self
39
    {
40
        return new static(var_export($value, true) . ' is unable to be serialized', 0, $previous);
41
    }
42
}
43