Passed
Push — master ( e297c9...6645eb )
by Dawid
02:47
created

ConfigException::forInvalidSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Igni\Application\Exception;
4
5
use Igni\Application\Config;
6
7
class ConfigException extends ApplicationException
8
{
9
    public static function forInvalidValue($key, $expectedType, $givenType): ConfigException
10
    {
11
        return new self("Invalid configuration at $key, expected $expectedType, given $givenType");
12
    }
13
14
    public static function forUnreadableDirectory(string $dir)
15
    {
16
        return new self("Could not read configuration dir $dir, make sure that dir exists and process has read access to it.");
17
    }
18
19
    public static function forUnsupportedFileType($path): ConfigException
20
    {
21
        return new self(sprintf(
22
            '%s does not does not recognize the file: %s',
23
            Config::class,
24
            $path
25
        ));
26
    }
27
28
    public static function forInvalidSource($source): ConfigException
29
    {
30
        return new self(sprintf(
31
            '%s::from($source) expects argument to be either string or array %s passed',
32
            Config::class,
33
            gettype($source)
34
        ));
35
    }
36
}
37