Author   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LibraryCatalog\Controller\V1\Transformer;
6
7
use LibraryCatalog\Controller\TransformerException;
8
use LibraryCatalog\Controller\TransformerInterface;
9
use LibraryCatalog\Entity\Author as Entity;
10
11
class Author implements TransformerInterface
12
{
13
    /**
14
     * @param $data
15
     * @return array
16
     * @throws TransformerException
17
     */
18 5
    public function transform($data): array
19
    {
20 5
        if (!($data instanceof Entity)) {
21 1
            throw new TransformerException("Tried to transform not an Author");
22
        }
23
        return [
24 4
            'id'        => $data->id ?? null,
25 4
            'name'      => $data->name ?? null,
26 4
            'birthdate' => $data->birthdate ?? null,
27 4
            'deathdate' => $data->deathdate ?? null,
28 4
            'biography' => $data->biography ?? null,
29 4
            'summary'   => $data->summary ?? null,
30
        ];
31
    }
32
}
33