OrderTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasOrders() 0 3 2
A setOrder() 0 3 1
A orders() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace OniBus\Query;
5
6
trait OrderTrait
7
{
8
    /**
9
     * @var Order
10
     */
11
    protected $orderBy;
12
13
    protected function setOrder(Order $orderBy)
14
    {
15
        $this->orderBy = $orderBy;
16
    }
17
18
    public function orders(): Order
19
    {
20
        return $this->orderBy ?? new Order();
21
    }
22
23
    public function hasOrders(): bool
24
    {
25
        return $this->orderBy instanceof Order && !$this->orderBy->isEmpty();
26
    }
27
}
28