Passed
Push — main ( e3d1bb...64bec1 )
by
unknown
31:25 queued 12s
created

FormatException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 39
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A missingExtension() 0 3 1
A invalidJSON() 0 3 1
A invalidMime() 0 3 1
A invalidFormatter() 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
 * FormatException
18
 */
19
class FormatException extends RuntimeException implements ExceptionInterface
20
{
21
    use DebugTraceableTrait;
22
23
    /**
24
     * Levée lorsque la classe instanciée n'existe pas.
25
     */
26
    public static function invalidFormatter(string $class)
27
    {
28 2
        return new static(lang('Format.invalidFormatter', [$class]));
29
    }
30
31
    /**
32
     * Lancé dans JSONFormatter lorsque le json_encode produit
33
     * un code d'erreur autre que JSON_ERROR_NONE et JSON_ERROR_RECURSION.
34
     */
35
    public static function invalidJSON(?string $error = null)
36
    {
37
        return new static(lang('Format.invalidJSON', [$error]));
38
    }
39
40
    /**
41
     * Levé lorsque le type MIME fourni n'a pas
42
     * classe Formatter définie.
43
     */
44
    public static function invalidMime(string $mime)
45
    {
46 2
        return new static(lang('Format.invalidMime', [$mime]));
47
    }
48
49
    /**
50
     * Lancé sur XMLFormatter lorsque l'extension `simplexml`
51
     * N'est pas installé.
52
     *
53
     * @codeCoverageIgnore
54
     */
55
    public static function missingExtension()
56
    {
57
        return new static(lang('Format.missingExtension'));
58
    }
59
}
60