ProductAdapter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A collection() 0 6 1
A __construct() 0 3 1
1
<?php
2
3
namespace Ronmrcdo\Inventory\Adapters;
4
5
use Ronmrcdo\Inventory\Resources\ProductResource;
6
use Ronmrcdo\Inventory\Adapters\BaseAdapter;
7
8
class ProductAdapter extends BaseAdapter
9
{
10
	/**
11
	 * Single resource transformer
12
	 * 
13
	 * @param mixed $model
14
	 */
15
	public function __construct($model)
16
	{
17
		parent::__construct(new ProductResource($model));
18
	}
19
20
	/**
21
	 * Static function for the collection
22
	 * 
23
	 * @param \Illuminate\Database\Eloquent\Model $model
24
	 * @return array
25
	 */
26
	public static function collection($collection): array
27
	{
28
		$resource = new self($collection);
29
		$resource->setResource(ProductResource::collection($collection));
30
31
		return $resource->transform();
32
	}
33
}