Test Failed
Push — master ( df1c42...178b51 )
by Mostafa
01:07 queued 14s
created

UploadEntityProperties::keepOldFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Mostafaznv\Larupload\Concerns\Storage\UploadEntity;
4
5
use Illuminate\Http\UploadedFile;
6
use Mostafaznv\Larupload\Enums\LaruploadFileType;
7
use Mostafaznv\Larupload\Enums\LaruploadMode;
8
use Mostafaznv\Larupload\Enums\LaruploadSecureIdsMethod;
9
use Mostafaznv\Larupload\UploadEntities;
10
11
trait UploadEntityProperties
12
{
13
    /**
14
     * File object
15
     *
16
     * @var UploadedFile|mixed
17
     */
18
    protected mixed $file;
19
20
    /**
21
     * Cover Object
22
     *
23
     * @var UploadedFile|mixed
24
     */
25
    protected mixed $cover;
26
27
    /**
28
     * Model ID / Secure ID
29
     * This property will be initiated only on retrieving model.
30
     */
31
    protected string $id;
32
33
    /**
34
     * Type of file in Larupload ecosystem
35
     *
36
     * @var LaruploadFileType|null
37
     */
38
    protected ?LaruploadFileType $type;
39
40
    /**
41
     * Mode of uploadable entity
42
     */
43
    protected LaruploadMode $mode;
44
45
    /**
46
     * Specify whether Larupload should generate a cover image for images and videos or not.
47
     */
48
    protected bool $generateCover;
49
50
    /**
51
     * Dominant color flag
52
     *
53
     * @var boolean
54
     */
55
    protected bool $dominantColor;
56
57
    /**
58
     * Dominant color quality
59
     *
60
     * @var int
61
     */
62
    protected int $dominantColorQuality = 10;
63
64
    /**
65
     * Specify whether Larupload should Keep old files or not
66
     */
67
    protected bool $keepOldFiles;
68
69
    /**
70
     * Specify whether Larupload should preserve files or not
71
     */
72
    protected bool $preserveFiles;
73
74
    /**
75
     * Specify whether Larupload should optimize image or not
76
     */
77
    protected bool $optimizeImage;
78
79
    /**
80
     * Specify SecurityIDs Method
81
     */
82
    protected LaruploadSecureIdsMethod $secureIdsMethod;
83
84
    /**
85
     * Uploaded flag to prevent infinite loop
86
     */
87
    protected bool $uploaded = false;
88
89
    /**
90
     * Output array to save in database
91
     *
92
     * @var array
93
     */
94
    protected array $output = [
95
        'name'           => null,
96
        'id'             => null,
97
        'size'           => null,
98
        'type'           => null,
99
        'mime_type'      => null,
100
        'width'          => null,
101
        'height'         => null,
102
        'duration'       => null,
103
        'dominant_color' => null,
104
        'format'         => null,
105
        'cover'          => null,
106
    ];
107
108
109
    public function generateCover(bool $status): UploadEntities
110
    {
111
        $this->generateCover = $status;
112
113
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
114
    }
115
116
    public function dominantColor(bool $status): UploadEntities
117
    {
118
        $this->dominantColor = $status;
119
120
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
121
    }
122
123
    public function dominantColorQuality(int $quality): UploadEntities
124
    {
125
        $this->dominantColorQuality = $quality;
126
127
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
128
    }
129
130
    public function isUploaded(): bool
131
    {
132
        return $this->uploaded;
133
    }
134
135
    public function keepOldFiles(bool $status): UploadEntities
136
    {
137
        $this->keepOldFiles = $status;
138
139
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
140
    }
141
142
    public function preserveFiles(bool $status): UploadEntities
143
    {
144
        $this->preserveFiles = $status;
145
146
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
147
    }
148
149
    public function optimizeImage(bool $status): UploadEntities
150
    {
151
        $this->optimizeImage = $status;
152
153
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
154
    }
155
156
    public function secureIdsMethod(LaruploadSecureIdsMethod $method): UploadEntities
157
    {
158
        $this->secureIdsMethod = $method;
159
160
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityProperties which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
161
    }
162
}
163