Completed
Push — master ( 4b87ed...9e1563 )
by Vasyl
02:41
created

SlugMakerOptions::doNotGenerateSlugsOnUpdate()   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 0
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 = 'name';
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 string */
26
    public $slugPrefix = '';
27
28
    /** @var string */
29
    public $slugSuffix = '';
30
31
    /** @var bool */
32
    public $removeSlugsOnDelete = true;
33
34
    public static function create(): self
35
    {
36
        return new static();
37
    }
38
39
    /**
40
     * @param $fieldName
41
     * @return \Fomvasss\SlugMaker\SlugMakerOptions
42
     */
43
    public function generateSlugsFrom($fieldName): self
44
    {
45
        $this->generateSlugFrom = $fieldName;
46
47
        return $this;
48
    }
49
50
    private function allowDuplicateSlugs(): self
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...
51
    {
52
        $this->generateUniqueSlugs = false;
53
54
        return $this;
55
    }
56
57
    public function slugsShouldBeNoLongerThan(int $maximumLength): self
58
    {
59
        $this->maximumLength = $maximumLength;
60
61
        return $this;
62
    }
63
64
    public function doNotGenerateSlugsOnCreate(): self
65
    {
66
        $this->generateSlugsOnCreate = false;
67
68
        return $this;
69
    }
70
71
    public function doNotGenerateSlugsOnUpdate(): self
72
    {
73
        $this->generateSlugsOnUpdate = false;
74
75
        return $this;
76
    }
77
78
    public function doNotRemoveSlugsOnDelete(): self
79
    {
80
        $this->removeSlugsOnDelete = false;
81
82
        return $this;
83
    }
84
85
    public function usingSeparator(string $separator): self
86
    {
87
        $this->slugSeparator = $separator;
88
89
        return $this;
90
    }
91
92
    public function addPrefixToSlug(string $prefix): self
93
    {
94
        $this->slugPrefix = $prefix;
95
96
        return $this;
97
    }
98
99
    public function addSuffixToSlug(string $suffix): self
100
    {
101
        $this->slugSuffix = $suffix;
102
103
        return $this;
104
    }
105
}
106