Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
4 / 6
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
ResourceDefinition
66.67% covered (warning)
66.67%
4 / 6
80.00% covered (warning)
80.00%
4 / 5
5.93
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addPropertyDefinition
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getProperties
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Maker\BoundedContext\Resources;
3
4use Apie\Core\Attributes\CmsIcon;
5use Apie\Core\Attributes\HideIdOnOverview;
6use Apie\Core\Attributes\Not;
7use Apie\Core\Attributes\RemovalCheck;
8use Apie\Core\Attributes\Requires;
9use Apie\Core\Attributes\RuntimeCheck;
10use Apie\Core\Attributes\StaticCheck;
11use Apie\Core\ContextConstants;
12use Apie\Core\Entities\EntityInterface;
13use Apie\Core\Identifiers\PascalCaseSlug;
14use Apie\Maker\BoundedContext\Dtos\PropertyDefinition;
15use Apie\Maker\BoundedContext\Identifiers\BoundedContextDefinitionIdentifier;
16use Apie\Maker\BoundedContext\Identifiers\ResourceDefinitionIdentifier;
17use Apie\Maker\BoundedContext\Lists\PropertyDefinitionList;
18use Apie\Maker\Enums\IdType;
19
20#[HideIdOnOverview]
21#[RemovalCheck(new StaticCheck())]
22#[CmsIcon('carbon:software-resource-cluster')]
23class ResourceDefinition implements EntityInterface
24{
25    public function __construct(
26        private ResourceDefinitionIdentifier $id,
27        #[RuntimeCheck(new Not(new Requires(ContextConstants::GET_ALL_OBJECTS)))]
28        public IdType $idType,
29        private PascalCaseSlug $name,
30        public BoundedContextDefinitionIdentifier $boundedContextId,
31        #[RuntimeCheck(new Not(new Requires(ContextConstants::GET_ALL_OBJECTS)))]
32        private PropertyDefinitionList $properties
33    ) {
34    }
35
36    public function getName(): PascalCaseSlug
37    {
38        return $this->name;
39    }
40
41    public function addPropertyDefinition(PropertyDefinition $propertyDefinition): self
42    {
43        $this->properties->append($propertyDefinition);
44        return $this;
45    }
46
47    public function getProperties(): PropertyDefinitionList
48    {
49        return $this->properties;
50    }
51
52    public function getId(): ResourceDefinitionIdentifier
53    {
54        return $this->id;
55    }
56}