Passed
Push — master ( 2ea67c...f4db78 )
by Chris
39:33
created

QueriedModelUpdaterBuilder::withQueryMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Processor\Builder;
4
5
use WebTheory\Saveyour\Enum\ServerRequestLocation;
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
    public function withQueryMethod(string $queryMethod): self
27
    {
28
        $this->queryMethod = $queryMethod;
29
30
        return $this;
31
    }
32
33
    public function withLookup(string $lookup): self
34
    {
35
        $this->lookup = $lookup;
36
37
        return $this;
38
    }
39
40
    public function withLocation(?ServerRequestLocation $location): self
41
    {
42
        $this->location = $location;
43
44
        return $this;
45
    }
46
47
    public function build(): QueriedModelUpdater
48
    {
49
        return new QueriedModelUpdater(
50
            $this->name,
51
            $this->fields,
52
            $this->repository,
53
            $this->queryMethod,
54
            $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

54
            /** @scrutinizer ignore-type */ $this->updateMethod,
Loading history...
55
            $this->lookup,
56
            $this->location,
57
            $this->commitMethod,
58
        );
59
    }
60
}
61