UrlException::mandatoryFromField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Neurony\Url\Exceptions;
4
5
use Exception;
6
7
class UrlException extends Exception
8
{
9
    /**
10
     * The exception to be thrown when the process of creating a url has failed.
11
     *
12
     * @return static
13
     */
14
    public static function createFailed(): self
15
    {
16
        return new static('Failed creating the url!');
17
    }
18
19
    /**
20
     * The exception to be thrown when the process of updating a url has failed.
21
     *
22
     * @return static
23
     */
24
    public static function updateFailed(): self
25
    {
26
        return new static('Failed updating the url!');
27
    }
28
29
    /**
30
     * The exception to be thrown when the process of deleting a url has failed.
31
     *
32
     * @return static
33
     */
34
    public static function deleteFailed(): self
35
    {
36
        return new static('Failed deleting the url!');
37
    }
38
39
    /**
40
     * The exception to be thrown when the "route url to" has not been supplied to the urlable functionality.
41
     *
42
     * @param string $class
43
     * @return static
44
     */
45 View Code Duplication
    public static function mandatoryRouting(string $class): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        return new static(
48
            'The model '.$class.' uses the HasUrl trait'.PHP_EOL.
49
            'You are required to set the routing from where Laravel will dispatch it\'s route requests.'.PHP_EOL.
50
            'You can do this from inside the getUrlOptions() method defined on the model.'
51
        );
52
    }
53
54
    /**
55
     * The exception to be thrown when the "from field" has not been supplied to the urlable functionality.
56
     *
57
     * @param string $class
58
     * @return static
59
     */
60 View Code Duplication
    public static function mandatoryFromField(string $class): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        return new static(
63
            'The model '.$class.' uses the HasUrl trait'.PHP_EOL.
64
            'You are required to set the field from where to generate the url slug ($fromField)'.PHP_EOL.
65
            'You can do this from inside the getUrlOptions() method defined on the model.'
66
        );
67
    }
68
69
    /**
70
     * The exception to be thrown when the "to field" has not been supplied to the urlable functionality.
71
     *
72
     * @param string $class
73
     * @return static
74
     */
75 View Code Duplication
    public static function mandatoryToField(string $class): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        return new static(
78
            'The model '.$class.' uses the HasUrl trait'.PHP_EOL.
79
            'You are required to set the field where to store the generated url slug ($toField)'.PHP_EOL.
80
            'You can do this from inside the getUrlOptions() method defined on the model.'
81
        );
82
    }
83
}
84