Completed
Push — master ( 02e991...6c3ee0 )
by Matthew
15:05 queued 12:47
created

FractalUtility::createItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Ps2alerts\Api\Utility;
4
5
use League\Fractal\Resource\Item;
6
use League\Fractal\Resource\Collection;
7
use League\Fractal\TransformerAbstract;
8
use Ps2alerts\Api\Contract\FractalAwareInterface;
9
use Ps2alerts\Api\Contract\FractalAwareTrait;
10
11
class FractalUtility implements FractalAwareInterface
12
{
13
    use FractalAwareTrait;
14
15
    /**
16
     * Creates the item array and returns it hence it came.
17
     *
18
     * @param  array               $item        The data to parse
19
     * @param  TransformerAbstract $transformer The transformer to be used
20
     *
21
     * @return array
22
     */
23 View Code Duplication
    public function createItem($item, TransformerAbstract $transformer)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $resource = new Item($item, $transformer);
26
        $data = $this->getFractalManager()->createData($resource);
27
28
        return $data->toArray();
29
    }
30
31
    /**
32
     * Creates a collection array and sends it back to hence it came.
33
     *
34
     * @param  array               $collection
35
     * @param  TransformerAbstract $transformer
36
     *
37
     * @return array
38
     */
39 View Code Duplication
    public function createCollection(array $collection, TransformerAbstract $transformer)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $resource = new Collection($collection, $transformer);
42
        $data = $this->getFractalManager()->createData($resource);
43
44
        return $data->toArray();
45
    }
46
}