Completed
Branch master (49dc1a)
by Yaro
01:42
created

Crumb::shouldBeShownOnCreatePage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Yaro\Jarboe\ViewComponents\Breadcrumbs;
4
5
class Crumb
6
{
7
    private $url;
8
    private $title;
9
    private $shouldBeShownOnListPage = true;
10
    private $shouldBeShownOnCreatePage = true;
11
    private $shouldBeShownOnEditPage = true;
12
    private $shouldBeShowOnHistoryPage = true;
13
14 9
    public function __construct($title = '', $url = '')
15
    {
16 9
        $this->url = $url;
17 9
        $this->title = $title;
18 9
    }
19
20 9
    public static function make($title = '', $url = '')
21
    {
22 9
        return new static($title, $url);
23
    }
24
25 1
    public function title($title)
26
    {
27 1
        $this->title = $title;
28
29 1
        return $this;
30
    }
31
32 1
    public function url($url)
33
    {
34 1
        $this->url = $url;
35
36 1
        return $this;
37
    }
38
39
    /**
40
     * @param null $model
41
     * @return string
42
     */
43 1 View Code Duplication
    public function getTitle($model = null)
44
    {
45 1
        $callback = $this->title;
46 1
        if (is_callable($callback)) {
47 1
            return $callback($model);
48
        }
49 1
        return $this->title;
50
    }
51
52
    /**
53
     * @param null $model
54
     * @return string
55
     */
56 1 View Code Duplication
    public function getUrl($model = null)
57
    {
58 1
        $callback = $this->url;
59 1
        if (is_callable($callback)) {
60 1
            return $callback($model);
61
        }
62 1
        return $this->url;
63
    }
64
65 4
    public function showOnListPage(bool $shouldBeShown = true)
66
    {
67 4
        $this->shouldBeShownOnListPage = $shouldBeShown;
68
69 4
        return $this;
70
    }
71
72 4
    public function showOnCreatePage(bool $shouldBeShown = true)
73
    {
74 4
        $this->shouldBeShownOnCreatePage = $shouldBeShown;
75
76 4
        return $this;
77
    }
78
79 4
    public function showOnEditPage(bool $shouldBeShown = true)
80
    {
81 4
        $this->shouldBeShownOnEditPage = $shouldBeShown;
82
83 4
        return $this;
84
    }
85
    
86 4
    public function showOnHistoryPage(bool $shouldBeShown = true)
87
    {
88 4
        $this->showOnHistoryPage = $shouldBeShown;
0 ignored issues
show
Bug introduced by
The property showOnHistoryPage does not seem to exist. Did you mean shouldBeShowOnHistoryPage?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
89
90 4
        return $this;
91
    }
92
93 2 View Code Duplication
    public function showOnlyOnListPage()
94
    {
95 2
        $this->showOnListPage(true);
96 2
        $this->showOnCreatePage(false);
97 2
        $this->showOnEditPage(false);
98 2
        $this->showOnHistoryPage(false);
99
100 2
        return $this;
101
    }
102
103 2 View Code Duplication
    public function showOnlyOnCreatePage()
104
    {
105 2
        $this->showOnListPage(false);
106 2
        $this->showOnCreatePage(true);
107 2
        $this->showOnEditPage(false);
108 2
        $this->showOnHistoryPage(false);
109
110 2
        return $this;
111
    }
112
113 2 View Code Duplication
    public function showOnlyOnEditPage()
114
    {
115 2
        $this->showOnListPage(false);
116 2
        $this->showOnCreatePage(false);
117 2
        $this->showOnEditPage(true);
118 2
        $this->showOnHistoryPage(false);
119
120 2
        return $this;
121
    }
122
123 View Code Duplication
    public function showOnlyOnHistoryPage()
124
    {
125
        $this->showOnListPage(false);
126
        $this->showOnCreatePage(false);
127
        $this->showOnEditPage(false);
128
        $this->showOnHistoryPage(true);
129
130
        return $this;
131
    }
132
133 5
    public function shouldBeShownOnEditPage(): bool
134
    {
135 5
        return $this->shouldBeShownOnEditPage;
136
    }
137
138 5
    public function shouldBeShownOnCreatePage(): bool
139
    {
140 5
        return $this->shouldBeShownOnCreatePage;
141
    }
142
143 5
    public function shouldBeShownOnListPage(): bool
144
    {
145 5
        return $this->shouldBeShownOnListPage;
146
    }
147
148
    public function shouldBeShownOnHistoryPage(): bool
149
    {
150
        return $this->shouldBeShowOnHistoryPage;
151
    }
152
}
153