Passed
Pull Request — main (#18)
by Dimitri
03:55
created

PublisherException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 27
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A collision() 0 3 1
A destinationNotAllowed() 0 3 1
A fileNotAllowed() 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
/**
15
 * Publisher Exception Class
16
 *
17
 * Gère les exceptions liées aux actions entreprises par un Publisher.
18
 */
19
class PublisherException extends FrameworkException
20
{
21
    /**
22
     * Lève lorsqu'un fichier doit être écrasé mais ne le peut pas.
23
     *
24
     * @param string $from Le fichier source
25
     * @param string $to   The destination file
26
     */
27
    public static function collision(string $from, string $to)
28
    {
29 4
        return new static(lang('Publisher.collision', [filetype($to), $from, $to]));
30
    }
31
32
    /**
33
     * Lève une fois donnée une destination qui ne figure pas dans la liste des répertoires autorisés.
34
     */
35
    public static function destinationNotAllowed(string $destination)
36
    {
37 2
        return new static(lang('Publisher.destinationNotAllowed', [$destination]));
38
    }
39
40
    /**
41
     * Lève lorsqu'un fichier ne correspond pas au modèle autorisé pour sa destination.
42
     */
43
    public static function fileNotAllowed(string $file, string $directory, string $pattern)
44
    {
45 2
        return new static(lang('Publisher.fileNotAllowed', [$file, $directory, $pattern]));
46
    }
47
}
48