EventObserver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 16
c 3
b 1
f 0
dl 0
loc 48
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A updated() 0 8 2
A deleted() 0 5 2
A created() 0 7 2
1
<?php
2
3
namespace Innoflash\Events\Observers;
4
5
use FaithGen\SDK\Traits\FileTraits;
6
use Innoflash\Events\Jobs\Saved\ProcessImage;
7
use Innoflash\Events\Jobs\Saved\S3Upload;
8
use Innoflash\Events\Jobs\Saved\UploadImage;
9
use Innoflash\Events\Models\Event;
10
11
class EventObserver
12
{
13
    use FileTraits;
14
15
    /**
16
     * Handle the event "created" event.
17
     *
18
     * @param  \App\Event  $event
0 ignored issues
show
Bug introduced by
The type App\Event 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...
19
     * @return void
20
     */
21
    public function created(Event $event)
22
    {
23
        if (request()->has('banner')) {
24
            UploadImage::withChain([
25
                new ProcessImage($event),
26
                new S3Upload($event),
27
            ])->dispatch($event, request('banner'));
28
        }
29
    }
30
31
    /**
32
     * Handle the event "updated" event.
33
     *
34
     * @param  \App\Event  $event
35
     * @return void
36
     */
37
    public function updated(Event $event)
38
    {
39
        if (request()->has('banner')) {
40
            $this->deleted($event);
41
            UploadImage::withChain([
42
                new ProcessImage($event),
43
                new S3Upload($event),
44
            ])->dispatch($event, request('banner'));
45
        }
46
    }
47
48
    /**
49
     * Handle the event "deleted" event.
50
     *
51
     * @param  \App\Event  $event
52
     * @return void
53
     */
54
    public function deleted(Event $event)
55
    {
56
        if ($event->image()->exists()) {
57
            $this->deleteFiles($event);
58
            $event->image()->delete();
59
        }
60
    }
61
}
62