Passed
Push — master ( cedc01...8bcd2b )
by Christopher
02:32
created

PropertyRef::getDomName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlgoWeb\ODataMetadata\MetadataV3\Edm;
6
7
use AlgoWeb\ODataMetadata\MetadataV3\DomBase;
8
use AlgoWeb\ODataMetadata\Writer\AttributeContainer;
9
use DOMElement;
10
11
/**
12
 * 2.1.6 PropertyRef.
13
 *
14
 * PropertyRef element refers to a declared property of an EntityType.
15
 *
16
 * The following is an example of PropertyRef.
17
 *
18
 *     <PropertyRef Name="CustomerId" />
19
 *
20
 * The following rules apply to the PropertyRef element:
21
 * - PropertyRef can contain any number of AnnotationAttribute attributes. The full names of the AnnotationAttribute
22
 *   attributes MUST NOT collide.
23
 * - PropertyRef MUST define the Name attribute. The Name attribute refers to the name of a Property defined in the
24
 *   declaring EntityType.
25
 * - In CSDL 2.0 and CSDL 3.0, PropertyRef can contain any number of AnnotationElement elements.
26
 *
27
 * @see https://www.odata.org/documentation/odata-version-3-0/common-schema-definition-language-csdl/#csdl6.3
28
 * XSD Type: TPropertyRef
29
 */
30
class PropertyRef extends EdmBase
31
{
32
33
    /**
34
     * @var string $name PropertyRef MUST define the Name attribute. The Name attribute refers to the name of a
35
     *             Property defined in the declaring EntityType.
36
     */
37
    private $name;
38
39
    public function __construct(string $name)
40
    {
41
        $this
42
            ->setName($name);
43
    }
44
45
    /**
46
     * Gets as name.
47
     *
48
     * @return string
49
     */
50
    public function getName(): string
51
    {
52
        return $this->name;
53
    }
54
55
    /**
56
     * Sets a new name.
57
     *
58
     * @param  string $name
59
     * @return self
60
     */
61
    public function setName(string $name): self
62
    {
63
        $this->name = $name;
64
        return $this;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getDomName(): string
71
    {
72
        return 'PropertyRef';
73
    }
74
75
    /**
76
     * @return array|AttributeContainer[]
77
     */
78
    public function getAttributes(): array
79
    {
80
        return [
81
            new AttributeContainer('Name', $this->getName())
82
        ];
83
    }
84
85
    /**
86
     * @return array|DomBase[]
87
     */
88
    public function getChildElements(): array
89
    {
90
        return [];
91
    }
92
}
93