SlugException::mandatoryToField()   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 SlugException extends Exception
8
{
9
    /**
10
     * The exception to be thrown when the "from field" has not been supplied to the sluggable functionality.
11
     *
12
     * @param string $class
13
     * @return static
14
     */
15 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...
16
    {
17
        return new static(
18
            'The model '.$class.' uses the HasSlug trait'.PHP_EOL.
19
            'You are required to set the field from where to generate the slug ($fromField)'.PHP_EOL.
20
            'You can do this from inside the getSlugOptions() method defined on the model.'
21
        );
22
    }
23
24
    /**
25
     * The exception to be thrown when the "to field" has not been supplied to the sluggable functionality.
26
     *
27
     * @param string $class
28
     * @return static
29
     */
30 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...
31
    {
32
        return new static(
33
            'The model '.$class.' uses the HasSlug trait'.PHP_EOL.
34
            'You are required to set the field where to store the generated slug ($toField)'.PHP_EOL.
35
            'You can do this from inside the getSlugOptions() method defined on the model.'
36
        );
37
    }
38
}
39