LocalBookRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 4
c 4
b 0
f 1
lcom 1
cbo 2
dl 0
loc 27
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 4 1
A save() 0 4 1
A getAll() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace Clearcode\EHLibrary\Infrastructure\Persistence;
4
5
use Clearcode\EHLibrary\Model\Book;
6
use Clearcode\EHLibrary\Model\BookRepository;
7
use Everzet\PersistedObjects\AccessorObjectIdentifier;
8
use Everzet\PersistedObjects\FileRepository;
9
10
class LocalBookRepository implements BookRepository
11
{
12
    /** @var FileRepository */
13
    private $file;
14
15
    public function clear()
16
    {
17
        $this->file->clear();
18
    }
19
20
    /** {@inheritdoc} */
21
    public function save(Book $book)
22
    {
23
        $this->file->save($book);
24
    }
25
26
    /** {@inheritdoc} */
27
    public function getAll()
28
    {
29
        return $this->file->getAll();
30
    }
31
32
    public function __construct()
33
    {
34
        $this->file = new FileRepository(__DIR__.'/../../../cache/books.db', new AccessorObjectIdentifier('id'));
35
    }
36
}
37