Test Failed
Pull Request — master (#20)
by Alexander
04:07 queued 01:32
created

PostRepository::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Blog;
6
7
use Cycle\ORM\ORMInterface;
8
use Cycle\ORM\Select;
9
use Cycle\ORM\Transaction;
10
use Yiisoft\Yii\Cycle\DataReader\SelectDataReader;
11
12
final class PostRepository extends Select\Repository
13
{
14
    private ORMInterface $orm;
15
16
    public function __construct(Select $select, ORMInterface $orm)
17
    {
18
        $this->orm = $orm;
19
        parent::__construct($select);
20
    }
21
22
    public function findAll(array $scope = [], array $orderBy = []): SelectDataReader
23
    {
24
        return new SelectDataReader(
25
            $this->select()->where($scope)->orderBy($orderBy)
26
        );
27
    }
28
29
    public function save(Post $user): void
30
    {
31
        $transaction = new Transaction($this->orm);
32
        $transaction->persist($user);
33
        $transaction->run();
34
    }
35
}
36