Collection::toJsonApiArray()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\JsonApi\Client;
6
7
use Swis\JsonApi\Client\Interfaces\DataInterface;
8
9
/**
10
 * @template TKey of int
11
 * @template TValue of \Swis\JsonApi\Client\Interfaces\ItemInterface
12
 *
13
 * @extends \Illuminate\Support\Collection<TKey, TValue>
14
 */
15
class Collection extends \Illuminate\Support\Collection implements DataInterface
16
{
17
    /**
18
     * Get the collection of items as a plain json api array.
19
     */
20 8
    public function toJsonApiArray(): array
21
    {
22 8
        return array_map(
23 8
            static fn ($value) => $value instanceof DataInterface ? $value->toJsonApiArray() : $value,
24 8
            $this->items
25 4
        );
26
    }
27
}
28