SlugObserver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A saving() 0 6 2
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace App\Models\DocsPage;
10
11
use App\Models\DocsPage;
12
use Illuminate\Support\Str;
13
14
/**
15
 * Class SlugObserver.
16
 */
17
class SlugObserver
18
{
19
    /**
20
     * @param DocsPage $page
21
     */
22
    public function saving(DocsPage $page): void
23
    {
24
        if (! $page->slug) {
25
            $page->slug = Str::slug($page->title);
26
        }
27
    }
28
}
29