ProcessImage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 2
A __construct() 0 3 1
1
<?php
2
3
namespace Innoflash\Events\Listeners\Guest\Saved;
4
5
use Illuminate\Contracts\Queue\ShouldQueue;
6
use Innoflash\Events\Events\Guest\Saved;
7
use Intervention\Image\ImageManager;
8
9
class ProcessImage implements ShouldQueue
10
{
11
    protected $imageManager;
12
13
    /**
14
     * Create the event listener.
15
     *
16
     * @return void
17
     */
18
    public function __construct(ImageManager $imageManager)
19
    {
20
        $this->imageManager = $imageManager;
21
    }
22
23
    /**
24
     * Handle the event.
25
     *
26
     * @param  Saved  $event
27
     *
28
     * @return void
29
     */
30
    public function handle(Saved $event)
31
    {
32
        if ($event->getGuest()->image()->exists()) {
33
            $ogImage = storage_path('app/public/events/original/').$event->getGuest()->image->name;
0 ignored issues
show
Bug introduced by
The property image does not seem to exist on Innoflash\Events\Models\Guest. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
34
            $thumb100 = storage_path('app/public/events/50-50/').$event->getGuest()->image->name;
35
36
            $this->imageManager->make($ogImage)->fit(50, 50, function ($constraint) {
37
                $constraint->upsize();
38
                $constraint->aspectRatio();
39
            }, 'center')->save($thumb100);
40
        }
41
    }
42
}
43