Passed
Push — main ( 1fe2cd...c1deb1 )
by Dimitri
04:10
created

FrameworkException   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 12.5%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 43
ccs 1
cts 8
cp 0.125
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A enabledZlibOutputCompression() 0 3 1
A noHandlers() 0 3 1
A fabricatorCreateFailed() 0 3 1
A missingExtension() 0 14 2
A copyError() 0 3 1
A invalidFile() 0 3 1
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