JsonApiAuthorTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

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