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

CustomBookRepository::findCustomBook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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