OrderTrait::setOrder()   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
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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