Completed
Push — 1.2-resource-custom-repositori... ( 442e79 )
by Kamil
33:47
created

CustomBookRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findCustomBook() 0 4 1
A findCustomBooks() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppBundle\Repository;
6
7
use AppBundle\Entity\Book;
8
use Sylius\Component\Resource\Repository\RepositoryInterface;
9
10
final class CustomBookRepository
11
{
12
    /** @var RepositoryInterface */
13
    private $repository;
14
15
    public function __construct(RepositoryInterface $repository)
16
    {
17
        $this->repository = $repository;
18
    }
19
20
    public function findCustomBook(string $author): ?Book
21
    {
22
        return $this->repository->findOneBy(['author' => $author]);
23
    }
24
25
    public function findCustomBooks(): iterable
26
    {
27
        return $this->repository->createPaginator();
28
    }
29
}
30