SongObserver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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