OrdersTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrders() 0 3 1
A addOrder() 0 3 1
A ordersToArray() 0 3 1
A getOrders() 0 3 1
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