Passed
Push — master ( 6b2979...464731 )
by Alex
04:00 queued 11s
created

ODataBagContent::setPropertyContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace POData\ObjectModel;
6
7
/**
8
 * Class ODataBagContent
9
 *  Represents value of a bag (collection) property. Bag can be of two types:
10
 *  (1) Primitive Bag
11
 *  (2) Complex Bag.
12
 */
13
class ODataBagContent
14
{
15
    /**
16
     * The type name of the element.
17
     *
18
     * @var string|null
19
     */
20
    private $type;
21
    /**
22
     * Represents elements of the bag.
23
     *
24
     * @var string[]|ODataPropertyContent[]|null
25
     */
26
    private $propertyContents = [];
27
28
    /**
29
     * ODataBagContent constructor.
30
     * @param string                          $type
31
     * @param ODataPropertyContent[]|string[] $propertyContents
32
     */
33
    public function __construct(string $type = null, array $propertyContents = null)
34
    {
35
        $this
36
            ->setType($type)
37
            ->setPropertyContents($propertyContents);
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43
    public function getType(): ?string
44
    {
45
        return $this->type;
46
    }
47
48
    /**
49
     * @param  string|null     $type
50
     * @return ODataBagContent
51
     */
52
    public function setType(?string $type): ODataBagContent
53
    {
54
        $this->type = $type;
55
        return $this;
56
    }
57
58
    /**
59
     * @return ODataPropertyContent[]|string[]
60
     */
61
    public function getPropertyContents(): ?array
62
    {
63
        return $this->propertyContents;
64
    }
65
66
    /**
67
     * @param  ODataPropertyContent[]|string[] $propertyContents
68
     * @return ODataBagContent
69
     */
70
    public function setPropertyContents(?array $propertyContents): ODataBagContent
71
    {
72
        $this->propertyContents = $propertyContents;
73
        return $this;
74
    }
75
76
    public function addPropertyContent($propertyContent)
77
    {
78
        $this->propertyContents[] = $propertyContent;
79
        return $this;
80
    }
81
}
82