TestTableOneTwoRepository   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 101
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A readCount() 0 3 1
A deleteEntity() 0 3 1
A getEntityClass() 0 3 1
A updateRow() 0 23 1
A create() 0 9 1
A read() 0 3 1
A updateEntity() 0 11 1
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Tests\Behat\Bootstrap\Generated\LightOrmMysql\Repository;
4
5
use Janisbiz\LightOrm\Dms\MySQL\Repository\AbstractRepository;
6
use Janisbiz\LightOrm\Tests\Behat\Bootstrap\Generated\LightOrmMysql\Entity\TestTableOneTwoEntity;
7
8
class TestTableOneTwoRepository extends AbstractRepository
9
{
10
    /**
11
     * @param int $testTableOneId
12
     * @param int $testTableTwoId
13
     */
14
    public function create($testTableOneId, $testTableTwoId)
15
    {
16
        $this
17
            ->createQueryBuilder(
18
                (new TestTableOneTwoEntity())
19
                    ->setTestTableOneId($testTableOneId)
20
                    ->setTestTableTwoId($testTableTwoId)
21
            )
22
            ->insert()
23
        ;
24
    }
25
26
    /**
27
     * @return TestTableOneTwoEntity[]
28
     */
29
    public function read()
30
    {
31
        return $this->createQueryBuilder()->orderBy(TestTableOneTwoEntity::COLUMN_TEST_TABLE_ONE_ID)->find();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...T_TABLE_ONE_ID)->find() returns the type Janisbiz\LightOrm\Entity\EntityInterface[]|string which is incompatible with the documented return type Janisbiz\LightOrm\Tests\...TestTableOneTwoEntity[].
Loading history...
32
    }
33
34
    /**
35
     * @return int
36
     */
37
    public function readCount()
38
    {
39
        return $this->createQueryBuilder()->count();
40
    }
41
42
    /**
43
     * @param int $testTableOneIdCurrent
44
     * @param int $testTableTwoIdCurrent
45
     * @param int $testTableOneId
46
     * @param int $testTableTwoId
47
     *
48
     * @return TestTableOneTwoEntity
49
     */
50
    public function updateRow(
51
        $testTableOneIdCurrent,
52
        $testTableTwoIdCurrent,
53
        $testTableOneId,
54
        $testTableTwoId
55
    ) {
56
        $testTableOneTwoEntity = $this
57
            ->createQueryBuilder()
58
            ->where('test_table_one_two.test_table_one_id = :test_table_one_id')
59
            ->where('test_table_one_two.test_table_two_id = :test_table_two_id')
60
            ->bind([
61
                'test_table_one_id' => $testTableOneIdCurrent,
62
                'test_table_two_id' => $testTableTwoIdCurrent,
63
            ])
64
            ->findOne()
65
        ;
66
67
        $testTableOneTwoEntity
68
            ->setTestTableOneId($testTableOneId)
0 ignored issues
show
Bug introduced by
The method setTestTableOneId() does not exist on Janisbiz\LightOrm\Entity\EntityInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Janisbiz\LightOrm\Entity\EntityInterface. ( Ignorable by Annotation )

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

68
            ->/** @scrutinizer ignore-call */ 
69
              setTestTableOneId($testTableOneId)
Loading history...
69
            ->setTestTableTwoId($testTableTwoId)
70
        ;
71
72
        return $this->createQueryBuilder($testTableOneTwoEntity)->update();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...OneTwoEntity)->update() also could return the type Janisbiz\LightOrm\Entity...nterface|boolean|string which is incompatible with the documented return type Janisbiz\LightOrm\Tests\...y\TestTableOneTwoEntity.
Loading history...
Bug introduced by
It seems like $testTableOneTwoEntity can also be of type string; however, parameter $entity of Janisbiz\LightOrm\Dms\My...y::createQueryBuilder() does only seem to accept Janisbiz\LightOrm\Entity\EntityInterface|null, maybe add an additional type check? ( Ignorable by Annotation )

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

72
        return $this->createQueryBuilder(/** @scrutinizer ignore-type */ $testTableOneTwoEntity)->update();
Loading history...
73
    }
74
75
    /**
76
     * @param TestTableOneTwoEntity $testTableOneTwoEntity
77
     * @param int $testTableOneId
78
     * @param int $testTableTwoId
79
     *
80
     * @return TestTableOneTwoEntity
81
     */
82
    public function updateEntity(
83
        TestTableOneTwoEntity $testTableOneTwoEntity,
84
        $testTableOneId,
85
        $testTableTwoId
86
    ) {
87
        $testTableOneTwoEntity
88
            ->setTestTableOneId($testTableOneId)
89
            ->setTestTableTwoId($testTableTwoId)
90
        ;
91
92
        return $this->createQueryBuilder($testTableOneTwoEntity)->update();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...OneTwoEntity)->update() also could return the type Janisbiz\LightOrm\Entity...nterface|boolean|string which is incompatible with the documented return type Janisbiz\LightOrm\Tests\...y\TestTableOneTwoEntity.
Loading history...
93
    }
94
95
    /**
96
     * @param TestTableOneTwoEntity $testTableOneTwoEntity
97
     */
98
    public function deleteEntity(TestTableOneTwoEntity $testTableOneTwoEntity)
99
    {
100
        $this->createQueryBuilder($testTableOneTwoEntity)->delete();
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    protected function getEntityClass(): string
107
    {
108
        return TestTableOneTwoEntity::class;
109
    }
110
}
111