PublishedDateObserver   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
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Models\Article;
12
13
use Carbon\Carbon;
14
use App\Models\Article;
15
16
/**
17
 * Class PublishedDateObserver.
18
 */
19
class PublishedDateObserver
20
{
21
    /**
22
     * @param Article $article
23
     */
24
    public function saving(Article $article)
25
    {
26
        if (! $article->published_at) {
27
            $article->published_at = Carbon::now();
28
        }
29
    }
30
}
31