WriteError   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fileWriteFailed() 0 6 1
A classExists() 0 4 1
A commandExists() 0 7 1
A seederExists() 0 7 1
1
<?php
2
3
namespace Yarak\Exceptions;
4
5
use Exception;
6
7
class WriteError extends Exception
8
{
9
    /**
10
     * Writing to the filesystem failed.
11
     *
12
     * @param string $path
13
     *
14
     * @return static
15
     */
16
    public static function fileWriteFailed($e, $path = '')
17
    {
18
        $message = "Writing to {$path} failed."."\n".$e;
19
20
        return new static($message);
21
    }
22
23
    /**
24
     * Writing to the filesystem failed because the given class exists.
25
     *
26
     * @param string $class
27
     *
28
     * @return static
29
     */
30
    public static function classExists($class)
31
    {
32
        return new static("Class {$class} already exists.");
33
    }
34
35
    /**
36
     * A command with the given name already exists.
37
     *
38
     * @param string $name
39
     *
40
     * @return static
41
     */
42
    public static function commandExists($name)
43
    {
44
        return new static(
45
            "Could not create command {$name}. ".
46
            "Command with name {$name} already exists."
47
        );
48
    }
49
50
    /**
51
     * A seeder with the given name already exists.
52
     *
53
     * @param string $name
54
     *
55
     * @return static
56
     */
57
    public static function seederExists($name)
58
    {
59
        return new static(
60
            "Could not create seeder {$name}. ".
61
            "Seeder with name {$name} already exists."
62
        );
63
    }
64
}
65