Issues (42)

src/Observers/SermonObserver.php (2 issues)

1
<?php
2
3
namespace FaithGen\Sermons\Observers;
4
5
use FaithGen\SDK\Traits\FileTraits;
6
use FaithGen\Sermons\Jobs\MessageFollowers;
7
use FaithGen\Sermons\Jobs\ProcessImage;
8
use FaithGen\Sermons\Jobs\S3Upload;
9
use FaithGen\Sermons\Jobs\UploadImage;
10
use FaithGen\Sermons\Models\Sermon;
11
12
class SermonObserver
13
{
14
    use FileTraits;
15
16
    /**
17
     * Handle the sermon "created" event.
18
     *
19
     * @param Sermon $sermon
20
     * @return void
21
     */
22
    public function created(Sermon $sermon)
23
    {
24
        MessageFollowers::withChain([
25
            new UploadImage($sermon, request('image')),
0 ignored issues
show
It seems like request('image') can also be of type array; however, parameter $image of FaithGen\Sermons\Jobs\UploadImage::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

25
            new UploadImage($sermon, /** @scrutinizer ignore-type */ request('image')),
Loading history...
26
            new ProcessImage($sermon),
27
            new S3Upload($sermon),
28
        ])->dispatch($sermon);
29
    }
30
31
    /**
32
     * Handle the sermon "updated" event.
33
     *
34
     * @param Sermon $sermon
35
     * @return void
36
     */
37
    public function updated(Sermon $sermon)
0 ignored issues
show
The parameter $sermon 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

37
    public function updated(/** @scrutinizer ignore-unused */ Sermon $sermon)

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...
38
    {
39
        //
40
    }
41
42
    /**
43
     * Handle the sermon "deleted" event.
44
     *
45
     * @param Sermon $sermon
46
     * @return void
47
     */
48
    public function deleted(Sermon $sermon)
49
    {
50
        if ($sermon->image()->exists()) {
51
            $this->deleteFiles($sermon);
52
            $sermon->image()->delete();
53
        }
54
    }
55
}
56