Passed
Pull Request — master (#66)
by Alex
02:50
created

AmbiguousEntitySetBinding::getBindings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlgoWeb\ODataMetadata\Library\Internal\Ambiguous;
6
7
use AlgoWeb\ODataMetadata\Enums\ContainerElementKind;
8
use AlgoWeb\ODataMetadata\Interfaces\IEntityContainer;
9
use AlgoWeb\ODataMetadata\Interfaces\IEntitySet;
10
use AlgoWeb\ODataMetadata\Interfaces\IEntityType;
11
use AlgoWeb\ODataMetadata\Interfaces\INavigationProperty;
12
use AlgoWeb\ODataMetadata\Interfaces\INavigationTargetMapping;
13
use AlgoWeb\ODataMetadata\Library\Internal\Bad\BadEntityType;
14
15
class AmbiguousEntitySetBinding extends AmbiguousBinding implements IEntitySet
16
{
17
    public function __construct(IEntitySet $first, IEntitySet $second)
18
    {
19
        parent::__construct($first, $second);
20
    }
21
22
    /**
23
     * Gets the kind of element of this container element.
24
     *
25
     * @return ContainerElementKind
26
     */
27
    public function getContainerElementKind(): ContainerElementKind
28
    {
29
        return ContainerElementKind::EntitySet();
30
    }
31
32
    /**
33
     *  Gets the container that contains this element.
34
     *
35
     * @return IEntityContainer|null
36
     */
37
    public function getContainer(): ?IEntityContainer
38
    {
39
        return 0 !== count($this->getBindings()) ? $this->getBindings()[0]->getContainer() : null;
40
    }
41
42
    /**
43
     * Gets the entity type contained in this entity set.
44
     *
45
     * @return IEntityType
46
     */
47
    public function getElementType(): IEntityType
48
    {
49
        return new BadEntityType('', iterable_to_array($this->getErrors()));
50
    }
51
52
    /**
53
     * Gets the navigation targets of this entity set.
54
     *
55
     * @return array|INavigationTargetMapping[]
56
     */
57
    public function getNavigationTargets(): array
58
    {
59
        return [];
60
    }
61
62
    /**
63
     * Finds the entity set that a navigation property targets.
64
     *
65
     * @param  INavigationProperty $navigationProperty the navigation property
66
     * @return IEntitySet|null     the entity set that the navigation property targets, or null if no such entity set exists
67
     */
68
    public function findNavigationTarget(INavigationProperty $navigationProperty): ?IEntitySet
69
    {
70
        return null;
71
    }
72
73
    /**
74
     * @return IEntitySet[]
75
     */
76
    public function getBindings(): array
77
    {
78
        /** @var IEntitySet[] $res */
79
        $res = parent::getBindings();
80
81
        return $res;
82
    }
83
}
84