SongObserver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 2
b 0
f 0
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setFileHashAsId() 0 3 1
A __construct() 0 3 1
A creating() 0 3 1
1
<?php
2
3
namespace App\Observers;
4
5
use App\Models\Song;
6
use App\Services\HelperService;
7
8
class SongObserver
9
{
10
    private $helperService;
11
12 45
    public function __construct(HelperService $helperService)
13
    {
14 45
        $this->helperService = $helperService;
15 45
    }
16
17 45
    public function creating(Song $song): void
18
    {
19 45
        $this->setFileHashAsId($song);
20 45
    }
21
22 45
    private function setFileHashAsId(Song $song): void
23
    {
24 45
        $song->id = $this->helperService->getFileHash($song->path);
25 45
    }
26
}
27