UserObserver::forceDeleted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
namespace FaithGen\SDK\Observers;
4
5
use FaithGen\SDK\Jobs\Users\ProcessImage;
6
use FaithGen\SDK\Jobs\Users\S3Upload;
7
use FaithGen\SDK\Jobs\Users\UploadImage;
8
use FaithGen\SDK\Models\User;
9
use FaithGen\SDK\Traits\FileTraits;
10
use Illuminate\Support\Facades\Hash;
11
use Illuminate\Support\Str;
12
13
class UserObserver
14
{
15
    use FileTraits;
16
17
    /**
18
     * Handle the user "created" event.
19
     *
20
     * @param \App\User $user
0 ignored issues
show
Bug introduced by
The type App\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
     * @return void
22
     */
23
    public function creating(User $user)
24
    {
25
        $user->id = (string) Str::uuid();
26
        $user->password = Hash::make(env('DEFAULT_PASSWORD', 'secret'));
27
    }
28
29
    public function created(User $user)
30
    {
31
        if (request()->has('image')) {
32
            UploadImage::withChain([
33
                new ProcessImage($user),
34
                new S3Upload($user),
35
            ])->dispatch($user, request('image'));
36
        }
37
    }
38
39
    /**
40
     * Handle the user "updated" event.
41
     *
42
     * @param \App\User $user
43
     * @return void
44
     */
45
    public function updated(User $user)
46
    {
47
        if (request()->has('image')) {
48
            $this->deleteFiles($user);
49
            UploadImage::withChain([
50
                new ProcessImage($user),
51
                new S3Upload($user),
52
            ])->dispatch($user, request('image'));
53
        }
54
    }
55
56
    /**
57
     * Handle the user "deleted" event.
58
     *
59
     * @param \App\User $user
60
     * @return void
61
     */
62
    public function deleted(User $user)
63
    {
64
        if ($user->image()->exists()) {
65
            $this->deleteFiles($user);
66
        }
67
    }
68
69
    /**
70
     * Handle the user "restored" event.
71
     *
72
     * @param \App\User $user
73
     * @return void
74
     */
75
    public function restored(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

75
    public function restored(/** @scrutinizer ignore-unused */ User $user)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
        //
78
    }
79
80
    /**
81
     * Handle the user "force deleted" event.
82
     *
83
     * @param \App\User $user
84
     * @return void
85
     */
86
    public function forceDeleted(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

86
    public function forceDeleted(/** @scrutinizer ignore-unused */ User $user)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
87
    {
88
        //
89
    }
90
}
91