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

SubresourceMetadata   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 0
dl 0
loc 37
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResourceClass() 0 4 1
A withResourceClass() 0 7 1
A isCollection() 0 4 1
A withCollection() 0 7 1
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