TransformsResources   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transformItem() 0 3 1
A transformCollection() 0 4 1
1
<?php
2
3
namespace Signifly\Shopify\Support;
4
5
use Illuminate\Support\Collection;
6
use Signifly\Shopify\REST\Resources\ApiResource;
7
8
trait TransformsResources
9
{
10
    protected function transformCollection(array $items, string $class): Collection
11
    {
12
        return collect($items)->map(function ($attributes) use ($class) {
0 ignored issues
show
Bug introduced by
$items of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

12
        return collect(/** @scrutinizer ignore-type */ $items)->map(function ($attributes) use ($class) {
Loading history...
13
            return $this->transformItem($attributes, $class);
14
        });
15
    }
16
17
    protected function transformItem(array $attributes, string $class): ApiResource
18
    {
19
        return new $class($attributes, $this);
20
    }
21
}
22