|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cerbero\LaravelDto; |
|
4
|
|
|
|
|
5
|
|
|
use Cerbero\Dto\Dto as BaseDto; |
|
6
|
|
|
use Cerbero\Dto\Manipulators\Listener as BaseListener; |
|
7
|
|
|
use Cerbero\LaravelDto\Manipulators\Listener; |
|
8
|
|
|
use Illuminate\Contracts\Support\Arrayable; |
|
9
|
|
|
use Illuminate\Contracts\Support\Jsonable; |
|
10
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
11
|
|
|
use Illuminate\Http\Request; |
|
12
|
|
|
use Illuminate\Support\Enumerable; |
|
|
|
|
|
|
13
|
|
|
use Illuminate\Support\Traits\Macroable; |
|
14
|
|
|
use JsonSerializable; |
|
15
|
|
|
use Traversable; |
|
16
|
|
|
|
|
17
|
|
|
use const Cerbero\Dto\CAST_PRIMITIVES; |
|
|
|
|
|
|
18
|
|
|
use const Cerbero\Dto\IGNORE_UNKNOWN_PROPERTIES; |
|
|
|
|
|
|
19
|
|
|
use const Cerbero\Dto\NONE; |
|
|
|
|
|
|
20
|
|
|
use const Cerbero\Dto\PARTIAL; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The data transfer object. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class Dto extends BaseDto implements Arrayable, Jsonable |
|
27
|
|
|
{ |
|
28
|
|
|
use Macroable; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Retrieve an instance of DTO from the given or current request |
|
32
|
|
|
* |
|
33
|
|
|
* @param Request|null $request |
|
34
|
|
|
* @param int $flags |
|
35
|
|
|
* @return self |
|
36
|
|
|
*/ |
|
37
|
3 |
|
public static function fromRequest(Request $request = null, int $flags = NONE): self |
|
38
|
|
|
{ |
|
39
|
3 |
|
$request = $request ?: Request::capture(); |
|
40
|
|
|
|
|
41
|
3 |
|
return static::make($request->all(), $flags | PARTIAL | IGNORE_UNKNOWN_PROPERTIES); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Retrieve an instance of DTO from the request |
|
46
|
|
|
* |
|
47
|
|
|
* @param Model $model |
|
48
|
|
|
* @param int $flags |
|
49
|
|
|
* @return self |
|
50
|
|
|
*/ |
|
51
|
3 |
|
public static function fromModel(Model $model, int $flags = NONE): self |
|
52
|
|
|
{ |
|
53
|
3 |
|
return static::make($model->toArray(), $flags | CAST_PRIMITIVES | PARTIAL | IGNORE_UNKNOWN_PROPERTIES); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Retrieve an instance of DTO from the given source |
|
58
|
|
|
* |
|
59
|
|
|
* @param mixed $source |
|
60
|
|
|
* @param int $flags |
|
61
|
|
|
* @return self |
|
62
|
|
|
*/ |
|
63
|
3 |
|
public static function from($source, int $flags = NONE): self |
|
64
|
|
|
{ |
|
65
|
3 |
|
if ($source instanceof Enumerable) { |
|
66
|
2 |
|
$source = $source->all(); |
|
67
|
3 |
|
} elseif ($source instanceof Arrayable) { |
|
68
|
3 |
|
$source = $source->toArray(); |
|
69
|
3 |
|
} elseif ($source instanceof Jsonable) { |
|
70
|
3 |
|
$source = json_decode($source->toJson(), true); |
|
71
|
3 |
|
} elseif ($source instanceof JsonSerializable) { |
|
72
|
3 |
|
$source = $source->jsonSerialize(); |
|
73
|
3 |
|
} elseif ($source instanceof Traversable) { |
|
74
|
3 |
|
$source = iterator_to_array($source); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
3 |
|
return static::make((array) $source, $flags); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Retrieve the listener instance |
|
82
|
|
|
* |
|
83
|
|
|
* @return BaseListener |
|
84
|
|
|
*/ |
|
85
|
24 |
|
protected function getListener(): BaseListener |
|
86
|
|
|
{ |
|
87
|
24 |
|
return Listener::instance(); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths