SlugException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 16
loc 32
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mandatoryFromField() 8 8 1
A mandatoryToField() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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