Completed
Push — master ( af09d7...7599bb )
by Dorian
02:06
created

Library   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 20
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gnutix\StarWarsLibrary\Model;
6
7
use Gnutix\Library\Model\Library as BaseLibrary;
8
use Gnutix\StarWarsLibrary\StarWarsLibraryInterface;
9
10
final class Library extends BaseLibrary implements StarWarsLibraryInterface
11
{
12
    /** @var Era[] */
13
    protected array $eras;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
14
15
    /**
16
     * @return Era[]
17
     */
18
    public function getEras(): array
19
    {
20
        return $this->eras;
21
    }
22
23
    /**
24
     * @return Book[]
25
     */
26
    public function getBooksByEra(string $eraId): array
27
    {
28
        /** @var Book[] $books */
29
        $books = array_filter($this->getBooks(), static function (Book $book) use ($eraId): bool {
30
            return $book->getChronologicalMarker()->getEra()->getId() === $eraId;
31
        });
32
33
        return $books;
34
    }
35
}
36