LTreeResource   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\LTree\Resources;
6
7
use Illuminate\Http\Resources\Json\JsonResource;
8
use Umbrellio\LTree\Helpers\LTreeNode;
9
use Umbrellio\LTree\Interfaces\LTreeInterface;
10
11
/**
12
 * @property LTreeNode $resource
13
 */
14
abstract class LTreeResource extends JsonResource
15
{
16 1
    final public function toArray($request)
17
    {
18 1
        return array_merge($this->toTreeArray($request, $this->resource->model), [
0 ignored issues
show
Bug introduced by
It seems like $this->resource->model can also be of type Illuminate\Database\Eloquent\Model; however, parameter $model of Umbrellio\LTree\Resource...Resource::toTreeArray() does only seem to accept Umbrellio\LTree\Interfaces\LTreeInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        return array_merge($this->toTreeArray($request, /** @scrutinizer ignore-type */ $this->resource->model), [
Loading history...
19 1
            'children' => static::collection($this->resource->getChildren())->toArray($request),
20 1
        ]);
21
    }
22
23
    /**
24
     * @param LTreeInterface $model
25
     */
26
    abstract protected function toTreeArray($request, $model);
27
}
28