Total Complexity | 12 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
5 | class UniqueSlug |
||
6 | { |
||
7 | /** @var SluggableContract */ |
||
8 | private $model; |
||
9 | |||
10 | /** @var array */ |
||
11 | private $blacklist; |
||
12 | |||
13 | /** @var \Closure */ |
||
14 | private $slugResolver; |
||
15 | |||
16 | public function __construct(SluggableContract $model, array $blacklist = []) |
||
17 | { |
||
18 | $this->model = $model; |
||
19 | $this->blacklist = $blacklist; |
||
20 | |||
21 | $this->slugResolver = function ($slug) { |
||
22 | return str_slug($slug); |
||
|
|||
23 | }; |
||
24 | } |
||
25 | |||
26 | public static function make($model, array $blacklist = []) |
||
27 | { |
||
28 | return new static($model, $blacklist); |
||
29 | } |
||
30 | |||
31 | public function slugResolver(\Closure $resolver) |
||
36 | } |
||
37 | |||
38 | public function get($title, SluggableContract $entity = null) |
||
52 | } |
||
53 | |||
54 | private function sluggify($value) |
||
55 | { |
||
56 | return call_user_func($this->slugResolver, $value); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * |
||
61 | * @param $slug |
||
62 | * @param SluggableContract $entity |
||
63 | * @return bool |
||
64 | */ |
||
65 | private function isSlugUnique($slug, SluggableContract $entity = null) |
||
74 | } |
||
75 | } |
||
76 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.