Passed
Push — master ( 451f84...6ac61a )
by Arkadiusz
06:05
created

InvalidArgumentException::arraySizeTooSmall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phpml\Exception;
6
7
use Exception;
8
9
class InvalidArgumentException extends Exception
10
{
11
    public static function arraySizeNotMatch(): self
12
    {
13
        return new self('Size of given arrays does not match');
14
    }
15
16
    public static function percentNotInRange($name): self
17
    {
18
        return new self(sprintf('%s must be between 0.0 and 1.0', $name));
19
    }
20
21
    public static function arrayCantBeEmpty(): self
22
    {
23
        return new self('The array has zero elements');
24
    }
25
26
    public static function arraySizeTooSmall(int $minimumSize = 2): self
27
    {
28
        return new self(sprintf('The array must have at least %d elements', $minimumSize));
29
    }
30
31
    public static function matrixDimensionsDidNotMatch(): self
32
    {
33
        return new self('Matrix dimensions did not match');
34
    }
35
36
    public static function inconsistentMatrixSupplied(): self
37
    {
38
        return new self('Inconsistent matrix supplied');
39
    }
40
41
    public static function invalidClustersNumber(): self
42
    {
43
        return new self('Invalid clusters number');
44
    }
45
46
    /**
47
     * @param mixed $target
48
     */
49
    public static function invalidTarget($target): self
50
    {
51
        return new self(sprintf('Target with value "%s" is not part of the accepted classes', $target));
52
    }
53
54
    public static function invalidStopWordsLanguage(string $language): self
55
    {
56
        return new self(sprintf('Can\'t find "%s" language for StopWords', $language));
57
    }
58
59
    public static function invalidLayerNodeClass(): self
60
    {
61
        return new self('Layer node class must implement Node interface');
62
    }
63
64
    public static function invalidLayersNumber(): self
65
    {
66
        return new self('Provide at least 1 hidden layer');
67
    }
68
69
    public static function invalidClassesNumber(): self
70
    {
71
        return new self('Provide at least 2 different classes');
72
    }
73
74
    public static function inconsistentClasses(): self
75
    {
76
        return new self('The provided classes don\'t match the classes provided in the constructor');
77
    }
78
79
    public static function fileNotFound(string $file): self
80
    {
81
        return new self(sprintf('File "%s" not found', $file));
82
    }
83
84
    public static function fileNotExecutable(string $file): self
85
    {
86
        return new self(sprintf('File "%s" is not executable', $file));
87
    }
88
89
    public static function pathNotFound(string $path): self
90
    {
91
        return new self(sprintf('The specified path "%s" does not exist', $path));
92
    }
93
94
    public static function pathNotWritable(string $path): self
95
    {
96
        return new self(sprintf('The specified path "%s" is not writable', $path));
97
    }
98
99
    public static function invalidOperator(string $operator): self
100
    {
101
        return new self(sprintf('Invalid operator "%s" provided', $operator));
102
    }
103
}
104