Completed
Push — master ( 866487...6bcace )
by Dorian
04:50
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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEras() 0 4 1
A getBooksByEra() 0 6 1
1
<?php
2
3
namespace Gnutix\StarWarsLibrary\Model;
4
5
use Gnutix\Library\Model\Library as BaseLibrary;
6
use Gnutix\StarWarsLibrary\StarWarsLibraryInterface;
7
8
/**
9
 * Star Wars Library
10
 */
11
final class Library extends BaseLibrary implements StarWarsLibraryInterface
12
{
13
    /** @var \Gnutix\StarWarsLibrary\Model\Era[] */
14
    protected $eras;
15
16
    /**
17
     * @return \Gnutix\StarWarsLibrary\Model\Era[]
18
     */
19
    public function getEras()
20
    {
21
        return $this->eras;
22
    }
23
24
    public function getBooksByEra(string $eraId)
25
    {
26
        return array_filter($this->getBooks(), static function (Book $book) use ($eraId): bool {
27
            return $book->getChronologicalMarker()->getEra()->getId() === $eraId;
28
        });
29
    }
30
}
31