Passed
Push — master ( ee6b03...f5a05a )
by Aleksandar
02:24
created

RelationalMapper::deleteMany()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
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;
0 ignored issues
show
Bug introduced by
The type ArekX\PQL\Orm\Attributes\MultiRelation 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 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)
0 ignored issues
show
Unused Code introduced by
The parameter $modelClass 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

100
    public function find(/** @scrutinizer ignore-unused */ string $modelClass)

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...
101
    {
102
103
    }
104
105
    public function save($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

105
    public function save(/** @scrutinizer ignore-unused */ $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...
106
    {
107
108
    }
109
110
    public function delete($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

110
    public function delete(/** @scrutinizer ignore-unused */ $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...
111
    {
112
113
    }
114
115
    public function insertMany(string $modelClass)
0 ignored issues
show
Unused Code introduced by
The parameter $modelClass 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

115
    public function insertMany(/** @scrutinizer ignore-unused */ string $modelClass)

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...
116
    {
117
118
    }
119
120
    public function updateMany(string $modelClass)
0 ignored issues
show
Unused Code introduced by
The parameter $modelClass 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

120
    public function updateMany(/** @scrutinizer ignore-unused */ string $modelClass)

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...
121
    {
122
123
    }
124
125
    public function deleteMany(string $modelClass)
0 ignored issues
show
Unused Code introduced by
The parameter $modelClass 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

125
    public function deleteMany(/** @scrutinizer ignore-unused */ string $modelClass)

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...
126
    {
127
128
    }
129
}