Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 0 |
1 | <?php |
||
13 | final class BlogService |
||
14 | { |
||
15 | private const POSTS_PER_PAGE = 10; |
||
16 | private PostRepository $postRepository; |
||
17 | |||
18 | 3 | public function __construct(PostRepository $postRepository) |
|
21 | } |
||
22 | |||
23 | 1 | public function getPosts(int $page): PaginatorInterface |
|
24 | { |
||
25 | 1 | $dataReader = $this->postRepository->findAll(); |
|
26 | |||
27 | 1 | return (new OffsetPaginator($dataReader)) |
|
28 | ->withPageSize(self::POSTS_PER_PAGE) |
||
29 | ->withCurrentPage($page); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param int $id |
||
34 | * |
||
35 | * @throws NotFoundException |
||
36 | * |
||
37 | * @return Post |
||
38 | */ |
||
39 | 2 | public function getPost(int $id): Post |
|
50 | } |
||
51 | } |
||
52 |