CommentRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSort() 0 3 1
A getReader() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Blog\Comment;
6
7
use App\Blog\Entity\Comment;
8
use Cycle\ORM\Select;
9
use Yiisoft\Data\Reader\DataReaderInterface;
10
use Yiisoft\Data\Reader\Sort;
11
use Yiisoft\Yii\Cycle\Data\Reader\EntityReader;
12
13
final class CommentRepository extends Select\Repository
14
{
15
    /**
16
     * @psalm-return DataReaderInterface<int, Comment>
17
     */
18 1
    public function getReader(): DataReaderInterface
19
    {
20 1
        return (new EntityReader($this->select()))
21 1
            ->withSort($this->getSort());
22
    }
23
24 1
    private function getSort(): Sort
25
    {
26 1
        return Sort::only(['id', 'public', 'created_at', 'post_id', 'user_id'])->withOrder(['id' => 'asc']);
27
    }
28
}
29