InvalidConversionParameter::shouldBeNumeric()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Spatie\MediaLibrary\Exceptions;
4
5
use Exception;
6
7
class InvalidConversionParameter extends Exception
8
{
9
    public static function invalidWidth()
10
    {
11
        return new static('Width should be numeric and greater than 0');
12
    }
13
14
    public static function invalidHeight()
15
    {
16
        return new static('Height should be numeric and greater than 0');
17
    }
18
19
    public static function invalidFormat(string $givenFormat, array $validFormats)
20
    {
21
        $validFormats = implode(', ', $validFormats);
22
23
        return new static("Format `{$givenFormat}` is not one of the allowed formats: {$validFormats}");
24
    }
25
26
    public static function invalidFit(string $givenFit, array $givenFits)
27
    {
28
        $givenFits = implode(', ', $givenFits);
29
30
        return new static("Format `{$givenFit}` is not one of the allowed formats: {$givenFits}");
31
    }
32
33
    public static function shouldBeNumeric(string $name, $value)
34
    {
35
        return new static("{$name} should be numeric. `{$value}` given.");
36
    }
37
38
    public static function shouldBeGreaterThanOne(string $name, $value)
39
    {
40
        return new static("{$name} should be greater than one. `{$value}` given.");
41
    }
42
}
43