Passed
Push — main ( 4d334c...0416fa )
by Seth
12:13 queued 10:38
created

File::getFilesystemDisk()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace SaasReady\Models;
4
5
use Carbon\Carbon;
0 ignored issues
show
Bug introduced by
The type Carbon\Carbon 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...
6
use Illuminate\Contracts\Filesystem\Filesystem;
0 ignored issues
show
Bug introduced by
The type Illuminate\Contracts\Filesystem\Filesystem 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...
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Factories\HasFactory 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...
8
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model 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...
9
use Illuminate\Database\Eloquent\Relations\MorphTo;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Relations\MorphTo 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...
10
use Illuminate\Database\Eloquent\SoftDeletes;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\SoftDeletes 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...
11
use Illuminate\Filesystem\FilesystemManager;
0 ignored issues
show
Bug introduced by
The type Illuminate\Filesystem\FilesystemManager 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...
12
use Illuminate\Support\Facades\Storage;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Storage 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...
13
use SaasReady\Database\Factories\FileFactory;
14
use SaasReady\Traits\EloquentBuilderMixin;
15
use SaasReady\Traits\HasUuid;
0 ignored issues
show
Bug introduced by
The type SaasReady\Traits\HasUuid 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...
16
17
/**
18
 * @property-read int $id
19
 * @property-read string $uuid
20
 * @property ?string $model_type
21
 * @property ?int $model_id
22
 * @property ?string $category
23
 * @property string $filename
24
 * @property string $original_filename
25
 * @property string $path
26
 * @property string $mime_type
27
 * @property int $size
28
 * @property string $source
29
 * @property ?Carbon $created_at
30
 * @property ?Carbon $updated_at
31
 * @property ?Carbon $deleted_at
32
 *
33
 * @property-read ?Model $model
34
 *
35
 * @mixin EloquentBuilderMixin
36
 */
37
class File extends Model
38
{
39
    use HasFactory;
40
    use SoftDeletes;
41
    use HasUuid;
42
43
    protected $table = 'files';
44
45
    protected $fillable = [
46
        'model_id',
47
        'model_type',
48
        'category',
49
        'filename',
50
        'original_filename',
51
        'size',
52
        'path',
53
        'mime_type',
54
        'source',
55
    ];
56
57
    protected $casts = [
58
        'size' => 'int',
59
        'model_id' => 'int',
60
    ];
61
62
    public function model(): MorphTo
63
    {
64
        return $this->morphTo('model');
65
    }
66
67
    /**
68
     * @codeCoverageIgnore
69
     */
70
    protected static function newFactory(): FileFactory
71
    {
72
        return FileFactory::new();
73
    }
74
75
    public function getFilesystemDisk(): Filesystem | FilesystemManager
76
    {
77
        return Storage::disk($this->source ?: null);
78
    }
79
}
80