AbstractType::getKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace jin2chen\ApiBundle\Response\Type;
6
7
use jin2chen\ApiBundle\Response\ResponseTypeInterface;
8
use League\Fractal\Resource\ResourceAbstract;
9
10
use function implode;
11
use function is_array;
12
13
abstract class AbstractType implements ResponseTypeInterface
14
{
15
    protected string $transformer;
16
    protected ?string $key;
17
    protected string $includes = '';
18
    protected array $meta = [];
19
20
    abstract public function asResource(): ResourceAbstract;
21
22 1
    public function withKey(string $key): static
23
    {
24 1
        $this->key = $key;
25
26 1
        return $this;
27
    }
28
29
    /**
30
     * @param string|list<string> $includes
0 ignored issues
show
Bug introduced by
The type jin2chen\ApiBundle\Response\Type\list 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...
31
     *
32
     * @return $this
33
     */
34 1
    public function withIncludes(string|array $includes): static
35
    {
36 1
        $this->includes = is_array($includes) ? implode(',', $includes) : $includes;
0 ignored issues
show
introduced by
The condition is_array($includes) is always true.
Loading history...
37
38 1
        return $this;
39
    }
40
41 1
    public function withMeta(array $meta): static
42
    {
43 1
        $this->meta = $meta;
44
45 1
        return $this;
46
    }
47
48 1
    public function getTransformer(): string
49
    {
50 1
        return $this->transformer;
51
    }
52
53 1
    public function getKey(): ?string
54
    {
55 1
        return $this->key;
56
    }
57
58 3
    public function getIncludes(): string
59
    {
60 3
        return $this->includes;
61
    }
62
63 1
    public function getMeta(): array
64
    {
65 1
        return $this->meta;
66
    }
67
}
68