TransformCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A getType() 0 3 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Collections;
5
6
use Level23\Druid\Transforms\TransformInterface;
7
8
/**
9
 * @extends \Level23\Druid\Collections\BaseCollection<TransformInterface>
10
 */
11
class TransformCollection extends BaseCollection
12
{
13
    /**
14
     * DimensionCollection constructor.
15
     *
16
     * @param \Level23\Druid\Transforms\TransformInterface ...$transforms
17
     */
18 6
    public function __construct(TransformInterface ...$transforms)
19
    {
20 6
        $this->items = array_values($transforms);
21
    }
22
23
    /**
24
     * We only accept objects of this type.
25
     *
26
     * @return string
27
     */
28 1
    public function getType(): string
29
    {
30 1
        return TransformInterface::class;
31
    }
32
33
    /**
34
     * Return an array representation of our items
35
     *
36
     * @return array<int,array<mixed>>
37
     */
38 4
    public function toArray(): array
39
    {
40 4
        return array_map(fn(TransformInterface $item) => $item->toArray(), $this->items);
41
    }
42
}