Completed
Push — master ( 7b8f41...eb47c5 )
by Kévin
02:52
created

SubresourceMetadata::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ApiPlatform\Core\Metadata\Property;
15
16
/**
17
 * Subresource metadata.
18
 *
19
 * @author Antoine Bluchet <[email protected]>
20
 */
21
final class SubresourceMetadata
22
{
23
    private $resourceClass;
24
    private $collection;
25
26
    public function __construct(string $resourceClass, bool $collection = false)
27
    {
28
        $this->resourceClass = $resourceClass;
29
        $this->collection = $collection;
30
    }
31
32
    public function getResourceClass(): string
33
    {
34
        return $this->resourceClass;
35
    }
36
37
    public function withResourceClass($resourceClass): self
38
    {
39
        $metadata = clone $this;
40
        $metadata->resourceClass = $resourceClass;
41
42
        return $metadata;
43
    }
44
45
    public function isCollection(): bool
46
    {
47
        return $this->collection;
48
    }
49
50
    public function withCollection(bool $collection): self
51
    {
52
        $metadata = clone $this;
53
        $metadata->collection = $collection;
54
55
        return $metadata;
56
    }
57
}
58