Passed
Pull Request — master (#572)
by Alexander
02:59 queued 01:28
created

PostRepository::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Blog\Entity\Post;
6
7
use Cycle\ORM\ORMInterface;
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\ORMInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Cycle\ORM\Select;
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Select was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Cycle\ORM\Transaction;
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Transaction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Yiisoft\Yii\Cycle\Data\Reader\EntityReader;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\Cycle\Data\Reader\EntityReader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
final class PostRepository extends Select\Repository
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Select\Repository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
    /**
23
     * @psalm-return EntityReader<array-key, Post>
24
     */
25
    public function findAll(array $scope = [], array $orderBy = []): EntityReader
26
    {
27
        /** @psalm-var EntityReader<array-key, Post> */
28
        return new EntityReader(
29
            $this
30
                ->select()
31
                ->where($scope)
32
                ->orderBy($orderBy)
33
        );
34
    }
35
36
    public function save(Post $user): void
37
    {
38
        $transaction = new Transaction($this->orm);
39
        $transaction->persist($user);
40
        $transaction->run();
41
    }
42
}
43