LocalBookRepository::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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