Completed
Push — master ( bbff6f...c51acf )
by Rafał
19:14 queued 09:31
created

Package::getExternalData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Bridge Component.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\Bridge\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\Common\Collections\Collection;
19
use SWP\Component\Common\Model\EnableableTrait;
20
use SWP\Component\Common\Model\SoftDeletableTrait;
21
use SWP\Component\Common\Model\TimestampableTrait;
22
23
class Package extends BaseContent implements PackageInterface
24
{
25
    use TimestampableTrait, SoftDeletableTrait, EnableableTrait;
26
27
    /**
28
     * @var Collection
29
     */
30
    protected $items;
31
32
    /**
33
     * @var string
34
     */
35
    protected $body;
36
37
    /**
38
     * @var Collection
39
     */
40
    protected $externalData;
41
42
    /**
43
     * @var Collection
44
     */
45
    protected $groups;
46
47
    /**
48
     * @var ItemInterface[]|Collection
49 12
     */
50
    protected $relatedItems;
51 12
52
    public function __construct()
53
    {
54
        parent::__construct();
55
56
        $this->items = new ArrayCollection();
57 8
        $this->groups = new ArrayCollection();
58
        $this->externalData = new ArrayCollection();
59 8
        $this->relatedItems = new ArrayCollection();
60 8
    }
61
62
    public function getItemsArray(): array
63
    {
64
        return $this->items->toArray();
65
    }
66
67
    public function getGroupsArray(): array
68
    {
69
        return $this->groups->toArray();
70
    }
71
72
    public function getItems(): Collection
73
    {
74
        return $this->items;
75
    }
76
77
    public function setItems(Collection $items)
78
    {
79
        $this->items = $items;
80
    }
81
82
    public function addItem(\SWP\Component\Bridge\Model\Item $item)
83
    {
84
        if (!$this->items->contains($item)) {
85
            $this->items->add($item);
86
            $item->setPackage($this);
87
        }
88
89
        return $this;
90
    }
91
92
    public function removeItem(\SWP\Component\Bridge\Model\Item $item)
93
    {
94
        if ($this->items->contains($item)) {
95 12
            $this->items->removeElement($item);
96
            $item->setPackage(null);
97 12
        }
98
    }
99
100
    public function getBody()
101
    {
102
        return $this->body;
103
    }
104
105
    public function setBody($body)
106
    {
107
        $this->body = $body;
108
    }
109
110
    public function getExternalData(): ?Collection
111
    {
112
        return $this->externalData;
113
    }
114
115
    public function setExternalData(Collection $externalData): void
116
    {
117
        $this->externalData = $externalData;
118
    }
119
120
    public function getGroups(): ?Collection
121
    {
122
        return $this->groups;
123
    }
124
125
    public function setGroups(?Collection $groups): void
126
    {
127
        $this->groups = $groups;
128
    }
129
130
    public function getRelatedItems(): Collection
131
    {
132
        return $this->relatedItems;
133
    }
134
135
    public function setRelatedItems(Collection $relatedItems): void
136
    {
137
        $this->relatedItems = $relatedItems;
138
    }
139
}
140