OrdersTrait::addOrder()   A
last analyzed

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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 31.01.19
6
 * Time: 9:44
7
 */
8
9
namespace Sf4\Api\Dto\Traits;
10
11
use Doctrine\Common\Collections\ArrayCollection;
12
use Sf4\Api\Dto\Order\OrderInterface;
13
14
trait OrdersTrait
15
{
16
17
    abstract protected function arrayCollectionToArray(ArrayCollection $items);
18
19
    /** @var ArrayCollection $orders */
20
    private $orders;
21
22
    /**
23
     * @return ArrayCollection
24
     */
25
    public function getOrders(): ArrayCollection
26
    {
27
        return $this->orders;
28
    }
29
30
    /**
31
     * @param ArrayCollection $orders
32
     */
33
    public function setOrders(ArrayCollection $orders): void
34
    {
35
        $this->orders = $orders;
36
    }
37
38
    /**
39
     * @param OrderInterface|null $order
40
     */
41
    public function addOrder(OrderInterface $order): void
42
    {
43
        $this->orders->add($order);
44
    }
45
46
    protected function ordersToArray(): array
47
    {
48
        return $this->arrayCollectionToArray($this->getOrders());
49
    }
50
}
51