Completed
Push — master ( f05ffa...605762 )
by Vasyl
117:24 queued 115:51
created

SlugMakerOptions::usingSeparator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Fomvasss\SlugMaker;
4
5
class SlugMakerOptions
6
{
7
    /** @var string|array|callable */
8
    public $generateSlugFrom;
9
10
    /** @var bool */
11
    public $generateUniqueSlugs = true;
12
13
    /** @var int */
14
    public $maximumLength = 250;
15
16
    /** @var bool */
17
    public $generateSlugsOnCreate = true;
18
19
    /** @var bool */
20
    public $generateSlugsOnUpdate = true;
21
22
    /** @var string */
23
    public $slugSeparator = '-';
24
25
    /** @var bool */
26
    public $removeSlugsOnDelete = true;
27
28
    public static function create(): SlugMakerOptions
29
    {
30
        return new static();
31
    }
32
33
    /**
34
     * @param $fieldName
35
     * @return \App\Models\SlugMaker\SlugMakerOptions
0 ignored issues
show
Bug introduced by
The type App\Models\SlugMaker\SlugMakerOptions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
     */
37
    public function generateSlugsFrom($fieldName): SlugMakerOptions
38
    {
39
        $this->generateSlugFrom = $fieldName;
40
41
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Fomvasss\SlugMaker\SlugMakerOptions which is incompatible with the documented return type App\Models\SlugMaker\SlugMakerOptions.
Loading history...
42
    }
43
44
    private function allowDuplicateSlugs(): SlugMakerOptions
0 ignored issues
show
Unused Code introduced by
The method allowDuplicateSlugs() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
45
    {
46
        $this->generateUniqueSlugs = false;
47
48
        return $this;
49
    }
50
51
    public function slugsShouldBeNoLongerThan(int $maximumLength): SlugMakerOptions
52
    {
53
        $this->maximumLength = $maximumLength;
54
55
        return $this;
56
    }
57
58
    public function doNotGenerateSlugsOnCreate(): SlugMakerOptions
59
    {
60
        $this->generateSlugsOnCreate = false;
61
62
        return $this;
63
    }
64
65
    public function doNotGenerateSlugsOnUpdate(): SlugMakerOptions
66
    {
67
        $this->generateSlugsOnUpdate = false;
68
69
        return $this;
70
    }
71
72
    public function doNotRemoveSlugsOnDelete(): SlugMakerOptions
73
    {
74
        $this->removeSlugsOnDelete = false;
75
76
        return $this;
77
    }
78
79
    public function usingSeparator(string $separator): SlugMakerOptions
80
    {
81
        $this->slugSeparator = $separator;
82
83
        return $this;
84
    }
85
}
86