Completed
Branch develop (c4bcdd)
by Stephen
06:03
created

Transformer::transformCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Spinen\Transformers;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Transformer
9
 *
10
 * @package Spinen\Transformers\Transformation
11
 */
12
abstract class Transformer
13
{
14
    /**
15
     * Loop through the items in the collection & run the transform method
16
     *
17
     * @param TransformableCollection $model
18
     *
19
     * @return $this
20
     */
21
    public function transformCollection(TransformableCollection $model)
22
    {
23
        return $model->transform([$this, 'transform']);
24
    }
25
26
    /**
27
     * The method that actually converts the data using the map in the class
28
     *
29
     * @param Model $model
30
     *
31
     * @return mixed
32
     */
33
    abstract public function transform(Model $model);
34
}
35