JsonApiAuthorTransformer::includePublished()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
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