Passed
Push — master ( a4f7f2...d3cc39 )
by Melech
04:09
created

NullManager   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 10
c 0
b 0
f 0
dl 0
loc 79
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A createQueryBuilder() 0 3 1
A createRepository() 0 3 1
A prepare() 0 3 1
A beginTransaction() 0 3 1
A query() 0 3 1
A inTransaction() 0 3 1
A commit() 0 3 1
A rollback() 0 3 1
A lastInsertId() 0 3 1
A ensureTransaction() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Orm;
15
16
use Valkyrja\Orm\Contract\Manager as Contract;
17
use Valkyrja\Orm\QueryBuilder\Factory\Contract\QueryBuilderFactory;
18
use Valkyrja\Orm\QueryBuilder\Factory\SqlQueryBuilderFactory;
19
use Valkyrja\Orm\Repository\Contract\Repository;
20
use Valkyrja\Orm\Statement\Contract\Statement;
21
use Valkyrja\Orm\Statement\NullStatement;
22
23
/**
24
 * Class NullManager.
25
 *
26
 * @author Melech Mizrachi
27
 */
28
class NullManager implements Contract
29
{
30
    /**
31
     * @inheritDoc
32
     */
33
    public function createRepository(string $entity): Repository
34
    {
35
        return new \Valkyrja\Orm\Repository\Repository($this, $entity);
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function createQueryBuilder(): QueryBuilderFactory
42
    {
43
        return new SqlQueryBuilderFactory();
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function beginTransaction(): bool
50
    {
51
        return true;
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57
    public function inTransaction(): bool
58
    {
59
        return true;
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65
    public function ensureTransaction(): void
66
    {
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function prepare(string $query): Statement
73
    {
74
        return new NullStatement();
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    public function query(string $query): Statement
81
    {
82
        return new NullStatement();
83
    }
84
85
    /**
86
     * @inheritDoc
87
     */
88
    public function commit(): bool
89
    {
90
        return true;
91
    }
92
93
    /**
94
     * @inheritDoc
95
     */
96
    public function rollback(): bool
97
    {
98
        return true;
99
    }
100
101
    /**
102
     * @inheritDoc
103
     */
104
    public function lastInsertId(string|null $table = null, string|null $idField = null): string
105
    {
106
        return 'id';
107
    }
108
}
109