Passed
Pull Request — main (#8)
by
unknown
15:18
created

FrameworkException::invalidFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Exceptions;
13
14
use RuntimeException;
15
16
/**
17
 * Class FrameworkException
18
 *
19
 * Une collection d'exceptions lancées par le framework
20
 * qui ne peut être déterminé qu'au moment de l'exécution.
21
 */
22
class FrameworkException extends RuntimeException implements ExceptionInterface
23
{
24
    use DebugTraceableTrait;
25
26
    public static function enabledZlibOutputCompression()
27
    {
28
        return new static(lang('Core.enabledZlibOutputCompression'));
29
    }
30
31
    public static function invalidFile(string $path)
32
    {
33 4
        return new static(lang('Core.invalidFile', [$path]));
34
    }
35
36
    public static function copyError(string $path)
37
    {
38
        return new static(lang('Core.copyError', [$path]));
39
    }
40
41
    public static function missingExtension(string $extension)
42
    {
43
        if (str_contains($extension, 'intl')) {
44
            // @codeCoverageIgnoreStart
45
            $message = sprintf(
46
                'The framework needs the following extension(s) installed and loaded: %s.',
47
                $extension
48
            );
49
            // @codeCoverageIgnoreEnd
50
        } else {
51
            $message = lang('Core.missingExtension', [$extension]);
52
        }
53
54
        return new static($message);
55
    }
56
57
    public static function noHandlers(string $class)
58
    {
59
        return new static(lang('Core.noHandlers', [$class]));
60
    }
61
62
    public static function fabricatorCreateFailed(string $table, string $reason)
63
    {
64
        return new static(lang('Fabricator.createFailed', [$table, $reason]));
65
    }
66
}
67