OrderByCollection::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Collections;
5
6
use Level23\Druid\OrderBy\OrderByInterface;
7
8
/**
9
 * @extends \Level23\Druid\Collections\BaseCollection<OrderByInterface>
10
 */
11
class OrderByCollection extends BaseCollection
12
{
13
    /**
14
     * OrderByCollection constructor.
15
     *
16
     * @param \Level23\Druid\OrderBy\OrderByInterface ...$orderByColumns
17
     */
18 23
    public function __construct(OrderByInterface ...$orderByColumns)
19
    {
20 23
        $this->items = array_values($orderByColumns);
21
    }
22
23
    /**
24
     * Return an array representation of our items
25
     *
26
     * @return array<array<string,string>>
27
     */
28 7
    public function toArray(): array
29
    {
30 7
        return array_map(fn(OrderByInterface $item) => $item->toArray(), $this->items);
31
    }
32
33
    /**
34
     * We only accept objects of this type.
35
     *
36
     * @return string
37
     */
38 17
    public function getType(): string
39
    {
40 17
        return OrderByInterface::class;
41
    }
42
}