Passed
Push — master ( ecb751...b15917 )
by Daniel
06:52
created

ComponentPosition::getSortCollection()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\ApiResource;
17
use Doctrine\Common\Collections\Collection;
18
use Silverback\ApiComponentsBundle\Annotation as Silverback;
19
use Silverback\ApiComponentsBundle\Entity\Utility\IdTrait;
20
use Silverback\ApiComponentsBundle\Entity\Utility\TimestampedTrait;
21
use Silverback\ApiComponentsBundle\Validator\Constraints as AcbAssert;
22
use Symfony\Component\Validator\Constraints as Assert;
23
24
/**
25
 * @author Daniel West <[email protected]>
26
 *
27
 * @Silverback\Timestamped
28
 * @ApiResource(attributes={"order"={"sortValue"="ASC"}})
29
 * @AcbAssert\ComponentPosition
30
 */
31
class ComponentPosition
32
{
33
    use IdTrait;
34
    use TimestampedTrait;
35
36
    /**
37
     * @Assert\NotNull()
38
     */
39
    public ComponentCollection $componentCollection;
40
41
    /**
42
     * @Assert\NotNull()
43
     */
44
    public AbstractComponent $component;
45
46
    /**
47
     * @Assert\NotNull()
48
     */
49
    public int $sortValue = 0;
50
51
    /**
52
     * @return Collection|AbstractComponent[]|null
53
     */
54
    public function getSortCollection(): ?Collection
55
    {
56
        return $this->componentCollection->componentPositions;
57
    }
58
}
59