Issues (339)

src/File.php (11 issues)

1
<?php
0 ignored issues
show
This file is missing a doc comment.
Loading history...
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Filename "File.php" doesn't match the expected filename "file.php"
Loading history...
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace UniSharp\Uploadable;
4
5
use Illuminate\Support\Facades\URL;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Facades\Storage;
8
use Illuminate\Database\Eloquent\Relations\MorphTo;
9
10
class File extends Model
11
{
0 ignored issues
show
Opening brace should be on the same line as the declaration for class File
Loading history...
12
    protected $fillable = ['name', 'mime', 'size', 'path', 'extra'];
13
14 8
    public static function boot(): void
15
    {
16 4
        parent::boot();
17
18 8
        static::deleted(function ($model) {
19 4
            Storage::delete($model->attributes['path']);
20 8
        });
21 4
    }
22
23 20
    public function uploadable(): MorphTo
24
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
25 20
        return $this->morphTo();
26
    }
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected //end uploadable()
Loading history...
27
28 2
    public function getPathAttribute(): ?string
29
    {
30 2
        if (!array_key_exists('path', $this->attributes)) {
31
            return null;
32
        }
33
34 2
        return URL::to($this->attributes['path']);
35
    }
36
}
0 ignored issues
show
Expected //end class
Loading history...
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
37