GenericBookTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 7 1
A includeAuthor() 0 8 2
1
<?php namespace League\Fractal\Test\Stub\Transformer;
2
3
use League\Fractal\TransformerAbstract;
4
5
class GenericBookTransformer extends TransformerAbstract
6
{
7
    protected $availableIncludes = [
8
        'author',
9
    ];
10
11
    public function transform(array $book)
12
    {
13
        $book['year'] = (int) $book['year'];
14
        unset($book['_author']);
15
16
        return $book;
17
    }
18
19
    public function includeAuthor(array $book)
20
    {
21
        if (! isset($book['_author'])) {
22
            return;
23
        }
24
25
        return $this->item($book['_author'], new GenericAuthorTransformer(), 'author');
26
    }
27
}
28