PostHeadersFinder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findPostHeaders() 0 12 1
1
<?php
2
3
namespace App\Modules\Comments\Domain\Logic;
4
5
use App\Modules\Comments\Api\Query\Response\FindCommentsPostHeadersQueryResponse;
6
use App\Modules\Comments\Domain\Repository\CommentsPostHeadersFindingRepositoryInterface;
7
use DusanKasan\Knapsack\Collection;
8
9
trait PostHeadersFinder
10
{
11
    /**
12
     * @param CommentsPostHeadersFindingRepositoryInterface $headersFindingRepository
13
     */
14
    public function __construct(
15 12
        private CommentsPostHeadersFindingRepositoryInterface $headersFindingRepository
16
    )
17
    {
18
    }
19 12
20
    /**
21
     * @return array<FindCommentsPostHeadersQueryResponse>
22
     */
23
    public function findPostHeaders(): array
24
    {
25 9
        return Collection::from($this->headersFindingRepository->findPostHeaders())
26
            ->map(function ($header) {
27 9
                return new FindCommentsPostHeadersQueryResponse(
28 9
                    $header->getId(),
29 8
                    $header->getTitle(),
30 8
                    $header->getTags(),
31 8
                    $header->getVersion()
32 8
                );
33 8
            })
34 8
            ->toArray();
35
    }
36
}