Test Failed
Pull Request — master (#87)
by Dmitriy
03:15
created

PostRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A save() 0 5 1
A findAll() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Blog\Entity\Post;
6
7
use Cycle\ORM\ORMInterface;
8
use Cycle\ORM\Select;
9
use Cycle\ORM\Transaction;
10
use Yiisoft\Yii\Cycle\Data\Reader\EntityReader;
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 = []): EntityReader
23
    {
24
        return new EntityReader(
25
            $this
26
                ->select()
27
                ->where($scope)
28
                ->orderBy($orderBy)
29
        );
30
    }
31
32
    public function save(Post $user): void
33
    {
34
        $transaction = new Transaction($this->orm);
0 ignored issues
show
Deprecated Code introduced by
The class Cycle\ORM\Transaction has been deprecated: since 2.0 use {@see \Cycle\ORM\EntityManager} ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

34
        $transaction = /** @scrutinizer ignore-deprecated */ new Transaction($this->orm);
Loading history...
35
        $transaction->persist($user);
36
        $transaction->run();
37
    }
38
}
39