NormalizerContextBuilder::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Normalizer;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
9
final class NormalizerContextBuilder implements NormalizerContextBuilderInterface
10
{
11
    /**
12
     * @deprecated
13
     *
14
     * @var string[]
15
     */
16
    private $groups = [];
17
18
    /**
19
     * @var array
20
     */
21
    private $attributes = [];
22
23
    /**
24
     * @var ServerRequestInterface|null
25
     */
26
    private $request;
27
28 3
    private function __construct()
29
    {
30 3
    }
31
32
    public static function create(): NormalizerContextBuilderInterface
33
    {
34
        return new self();
35 3
    }
36
37 3
    /**
38
     * @deprecated
39
     *
40
     * @param string[] $groups
41
     */
42
    public function setGroups(array $groups): NormalizerContextBuilderInterface
43
    {
44
        $this->groups = $groups;
0 ignored issues
show
Deprecated Code introduced by
The property Chubbyphp\Serialization\...ContextBuilder::$groups has been deprecated. ( Ignorable by Annotation )

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

44
        /** @scrutinizer ignore-deprecated */ $this->groups = $groups;
Loading history...
45
46
        return $this;
47 1
    }
48
49 1
    public function setAttributes(array $attributes): NormalizerContextBuilderInterface
50
    {
51 1
        $this->attributes = $attributes;
52
53
        return $this;
54
    }
55
56
    public function setRequest(ServerRequestInterface $request = null): NormalizerContextBuilderInterface
57
    {
58
        $this->request = $request;
59 1
60
        return $this;
61 1
    }
62
63 1
    public function getContext(): NormalizerContextInterface
64
    {
65
        return new NormalizerContext($this->groups, $this->request, $this->attributes);
0 ignored issues
show
Deprecated Code introduced by
The property Chubbyphp\Serialization\...ContextBuilder::$groups has been deprecated. ( Ignorable by Annotation )

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

65
        return new NormalizerContext(/** @scrutinizer ignore-deprecated */ $this->groups, $this->request, $this->attributes);
Loading history...
66
    }
67
}
68