Test Failed
Push — master ( ba1a9c...19f0e1 )
by Mostafa
08:40
created

LaraStandalone   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 26
dl 0
loc 154
rs 10
c 2
b 0
f 0
wmc 18

12 Methods

Rating   Name   Duplication   Size   Complexity  
A updateCover() 0 7 2
A handleFFMpegQueue() 0 7 2
A meta() 0 7 2
A urls() 0 7 2
A make() 0 3 1
A url() 0 7 2
A detachCover() 0 7 2
A setOutput() 0 3 1
A deleted() 0 3 1
A download() 0 3 1
A saved() 0 3 1
A internalException() 0 3 1
1
<?php
2
3
namespace Mostafaznv\Larupload\Helpers;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\UploadedFile;
9
use Mostafaznv\Larupload\LaruploadEnum;
10
use Mostafaznv\Larupload\UploadEntities;
11
use Symfony\Component\HttpFoundation\StreamedResponse;
12
13
trait LaraStandalone
14
{
15
    /**
16
     * @param string $style
17
     * @return null|string
18
     * @throws Exception
19
     * @internal
20
     */
21
    public function url(string $style = LaruploadEnum::ORIGINAL_FOLDER): ?string
22
    {
23
        if ($this->internalFunctionIsCallable) {
24
            return parent::url($style);
25
        }
26
27
        self::internalException();
28
    }
29
30
    /**
31
     * @param string|null $key
32
     * @return object|string|integer|null
33
     * @throws Exception
34
     * @internal
35
     */
36
    public function meta(string $key = null)
37
    {
38
        if ($this->internalFunctionIsCallable) {
39
            return parent::meta($key);
40
        }
41
42
        self::internalException();
43
    }
44
45
    /**
46
     * @return object
47
     * @throws Exception
48
     * @internal
49
     */
50
    public function urls(): object
51
    {
52
        if ($this->internalFunctionIsCallable) {
53
            return parent::urls();
54
        }
55
56
        self::internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return object. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
57
    }
58
59
    /**
60
     * @param bool $isLastOne
61
     * @throws Exception
62
     * @internal
63
     */
64
    public function handleFFMpegQueue(bool $isLastOne = false): void
65
    {
66
        if ($this->internalFunctionIsCallable) {
67
            parent::handleFFMpegQueue($isLastOne);
68
        }
69
        else {
70
            self::internalException();
71
        }
72
    }
73
74
    /**
75
     * @param UploadedFile $file
76
     * @return bool
77
     * @throws Exception
78
     * @internal
79
     */
80
    public function updateCover(UploadedFile $file): bool
81
    {
82
        if ($this->internalFunctionIsCallable) {
83
            return parent::updateCover($file);
84
        }
85
86
        self::internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
87
    }
88
89
    /**
90
     * @return bool
91
     * @throws Exception
92
     * @internal
93
     */
94
    public function detachCover(): bool
95
    {
96
        if ($this->internalFunctionIsCallable) {
97
            return parent::detachCover();
98
        }
99
100
        self::internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
101
    }
102
103
    /****** not call callable ******************************************************************************************/
104
105
    /**
106
     * @param string $name
107
     * @param string $mode
108
     * @return UploadEntities
109
     * @throws Exception
110
     * @internal
111
     */
112
    public static function make(string $name, string $mode = LaruploadEnum::HEAVY_MODE): UploadEntities
0 ignored issues
show
Unused Code introduced by
The parameter $name 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

112
    public static function make(/** @scrutinizer ignore-unused */ string $name, string $mode = LaruploadEnum::HEAVY_MODE): UploadEntities

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...
Unused Code introduced by
The parameter $mode 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

112
    public static function make(string $name, /** @scrutinizer ignore-unused */ string $mode = LaruploadEnum::HEAVY_MODE): UploadEntities

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...
113
    {
114
        self::internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
115
    }
116
117
    /**
118
     * @param Model $model
119
     * @return Model
120
     * @throws Exception
121
     * @internal
122
     */
123
    public function saved(Model $model): Model
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

123
    public function saved(/** @scrutinizer ignore-unused */ Model $model): Model

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...
124
    {
125
        self::internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Model. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
126
    }
127
128
    /**
129
     * @param Model $model
130
     * @throws Exception
131
     * @internal
132
     */
133
    public function deleted(Model $model): void
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

133
    public function deleted(/** @scrutinizer ignore-unused */ Model $model): void

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...
134
    {
135
        self::internalException();
136
    }
137
138
    /**
139
     * @param string $style
140
     * @return RedirectResponse|StreamedResponse|null
141
     * @throws Exception
142
     * @internal
143
     */
144
    public function download(string $style = 'original')
0 ignored issues
show
Unused Code introduced by
The parameter $style 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

144
    public function download(/** @scrutinizer ignore-unused */ string $style = 'original')

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...
145
    {
146
        self::internalException();
147
    }
148
149
    /**
150
     * @param Model $model
151
     * @throws Exception
152
     * @internal
153
     */
154
    public function setOutput(Model $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

154
    public function setOutput(/** @scrutinizer ignore-unused */ Model $model)

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...
155
    {
156
        self::internalException();
157
    }
158
159
    /**
160
     * Throw exception for internal functions
161
     *
162
     * @throws Exception
163
     */
164
    protected static function internalException()
165
    {
166
        throw new Exception('This function flagged as @internal and is not available on standalone uploader.');
167
    }
168
}
169