Passed
Pull Request — master (#73)
by Daniel
06:32
created

ComponentCollection   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 35
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[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 Silverback\ApiComponentsBundle\Entity\Core;
15
16
use ApiPlatform\Core\Annotation\ApiProperty;
17
use ApiPlatform\Core\Annotation\ApiResource;
18
use Doctrine\Common\Collections\ArrayCollection;
19
use Doctrine\Common\Collections\Collection;
20
use Silverback\ApiComponentsBundle\Annotation as Silverback;
21
use Silverback\ApiComponentsBundle\Entity\Utility\IdTrait;
22
use Silverback\ApiComponentsBundle\Entity\Utility\TimestampedTrait;
23
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
24
use Symfony\Component\Validator\Constraints as Assert;
25
26
/**
27
 * @author Daniel West <[email protected]>
28
 *
29
 * @Silverback\Timestamped
30
 * @ApiResource
31
 * @UniqueEntity(fields={"reference"}, message="There is already a ComponentCollection resource with that reference.")
32
 */
33
class ComponentCollection
34
{
35
    use IdTrait;
36
    use TimestampedTrait;
37
38
    /**
39
     * @Assert\NotBlank(message="A component collection must have a reference")
40
     */
41
    public string $reference;
42
43
    /**
44
     * @var Collection|Layout[]
45
     */
46
    public $layouts;
47
48
    /**
49
     * @var Collection|PageTemplate[]
50
     */
51
    public Collection $pageTemplates;
52
53
    /**
54
     * @ApiProperty(writable=false)
55
     *
56
     * @var Collection|AbstractComponent[]
57
     */
58
    public Collection $components;
59
60
    /**
61
     * @var Collection|ComponentPosition[]
62
     */
63
    public Collection $componentPositions;
64
65
    public function __construct()
66
    {
67
        $this->componentPositions = new ArrayCollection();
68
    }
69
}
70