JsonApiAuthorTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
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 26
rs 10

2 Methods

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