Passed
Push — master ( 956624...05ed8c )
by Bertrand
08:49
created

RemoveAvatar::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
4
namespace App\Src\UseCases\Domain\Users;
5
6
7
use App\User;
8
9
class RemoveAvatar
10
{
11
    public function execute(string $uuid)
12
    {
13
        $user = User::query()->where('uuid', $uuid)->first();
14
        if(!isset($user)){
15
            return null;
16
        }
17
        $pathPicture = $user->path_picture;
18
        $user->path_picture = '';
19
        $user->save();
20
21
        unlink(storage_path($pathPicture));
22
    }
23
}
24