1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ArekX\PQL\Orm; |
4
|
|
|
|
5
|
|
|
use ArekX\PQL\Contracts\Driver; |
6
|
|
|
use ArekX\PQL\Contracts\QueryBuilder; |
7
|
|
|
use ArekX\PQL\Orm\Attributes\Column; |
8
|
|
|
use ArekX\PQL\Orm\Attributes\MultiRelation; |
|
|
|
|
9
|
|
|
use ArekX\PQL\Orm\Attributes\Table; |
10
|
|
|
use ReflectionClass; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Relational Mapper for mapping |
14
|
|
|
* models to tables. |
15
|
|
|
* |
16
|
|
|
*/ |
17
|
|
|
class RelationalMapper |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Current driver in use. |
21
|
|
|
* @var Driver |
22
|
|
|
*/ |
23
|
|
|
public Driver $driver; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Current query builder in use. |
27
|
|
|
* |
28
|
|
|
* @var QueryBuilder |
29
|
|
|
*/ |
30
|
|
|
public QueryBuilder $builder; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Compiler for model structure |
34
|
|
|
* |
35
|
|
|
* @var ModelCompiler |
36
|
|
|
*/ |
37
|
|
|
protected ModelCompiler $compiler; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Creates a new instance of this mapper |
41
|
|
|
* |
42
|
|
|
* @param Driver|null $driver Driver to be set to be used |
43
|
|
|
* @param QueryBuilder|null $builder Builder to be used |
44
|
|
|
* @return static |
45
|
|
|
*/ |
46
|
1 |
|
public static function create(?Driver $driver = null, ?QueryBuilder $builder = null): static |
47
|
|
|
{ |
48
|
1 |
|
return new static($driver, $builder); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Creates new instance of this mapper |
53
|
|
|
* |
54
|
|
|
* @param Driver|null $driver Driver to be set to be used |
55
|
|
|
* @param QueryBuilder|null $builder Builder to be used |
56
|
|
|
*/ |
57
|
1 |
|
public function __construct(?Driver $driver = null, ?QueryBuilder $builder = null) |
58
|
|
|
{ |
59
|
1 |
|
if ($driver) { |
60
|
1 |
|
$this->useDriver($driver); |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
if ($builder) { |
64
|
1 |
|
$this->useBuilder($builder); |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
$this->compiler = new ModelCompiler(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Set a driver to be used for queries. |
72
|
|
|
* |
73
|
|
|
* @param Driver $driver Driver to be used. |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
1 |
|
public function useDriver(Driver $driver): static |
77
|
|
|
{ |
78
|
1 |
|
$this->driver = $driver; |
79
|
1 |
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set query builder to be used. |
84
|
|
|
* |
85
|
|
|
* @param QueryBuilder $builder Builder to be used. |
86
|
|
|
* @return $this |
87
|
|
|
*/ |
88
|
1 |
|
public function useBuilder(QueryBuilder $builder): static |
89
|
|
|
{ |
90
|
1 |
|
$this->builder = $builder; |
91
|
1 |
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
1 |
|
public function toModelStructure(string $modelClass): array |
96
|
|
|
{ |
97
|
1 |
|
return $this->compiler->resolve($modelClass); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function find(string $modelClass) |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function save($model) |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
|
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function delete($model) |
|
|
|
|
111
|
|
|
{ |
112
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function insertMany(string $modelClass) |
|
|
|
|
116
|
|
|
{ |
117
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function updateMany(string $modelClass) |
|
|
|
|
121
|
|
|
{ |
122
|
|
|
|
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function deleteMany(string $modelClass) |
|
|
|
|
126
|
|
|
{ |
127
|
|
|
|
128
|
|
|
} |
129
|
|
|
} |
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