QueriedModelUpdaterBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 58
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withQueryMethod() 0 5 1
A withLocation() 0 5 1
A withLookup() 0 5 1
A build() 0 11 1
1
<?php
2
3
namespace WebTheory\Saveyour\Processor\Builder;
4
5
use WebTheory\Saveyour\Enum\ServerRequestLocation;
0 ignored issues
show
Bug introduced by
The type WebTheory\Saveyour\Enum\ServerRequestLocation 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...
6
use WebTheory\Saveyour\Processor\Builder\Abstracts\AbstractModelUpdaterBuilder;
7
use WebTheory\Saveyour\Processor\QueriedModelUpdater;
8
9
class QueriedModelUpdaterBuilder extends AbstractModelUpdaterBuilder
10
{
11
    /**
12
     * Method on the repository to query for the model
13
     */
14
    protected string $queryMethod;
15
16
    /**
17
     * Parameter name to on the request that contains repository query data
18
     */
19
    protected string $lookup;
20
21
    /**
22
     * Place to look for repository query data in the request
23
     */
24
    protected ServerRequestLocation $location;
25
26
    /**
27
     * @return $this
28
     */
29
    public function withQueryMethod(string $queryMethod): QueriedModelUpdaterBuilder
30
    {
31
        $this->queryMethod = $queryMethod;
32
33
        return $this;
34
    }
35
36
    /**
37
     * @return $this
38
     */
39
    public function withLookup(string $lookup): QueriedModelUpdaterBuilder
40
    {
41
        $this->lookup = $lookup;
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return $this
48
     */
49
    public function withLocation(?ServerRequestLocation $location): QueriedModelUpdaterBuilder
50
    {
51
        $this->location = $location;
52
53
        return $this;
54
    }
55
56
    public function build(): QueriedModelUpdater
57
    {
58
        return new QueriedModelUpdater(
59
            $this->name,
60
            $this->fields,
61
            $this->repository,
62
            $this->queryMethod,
63
            $this->updateMethod,
0 ignored issues
show
Bug introduced by
It seems like $this->updateMethod can also be of type null; however, parameter $updateMethod of WebTheory\Saveyour\Proce...lUpdater::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

63
            /** @scrutinizer ignore-type */ $this->updateMethod,
Loading history...
64
            $this->lookup,
65
            $this->location,
66
            $this->commitMethod,
67
        );
68
    }
69
}
70