Completed
Push — master ( e26ed0...acc468 )
by Sergei
113:25 queued 48:22
created

Configuration   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Test Coverage

Coverage 54.17%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
eloc 11
c 2
b 0
f 0
dl 0
loc 86
rs 10
ccs 13
cts 24
cp 0.5417

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getResultCacheImpl() 0 3 1
A getSQLLogger() 0 3 1
A getAutoCommit() 0 3 1
A setResultCacheImpl() 0 3 1
A getSchemaAssetsFilter() 0 3 1
A setAutoCommit() 0 3 1
A setSchemaAssetsFilter() 0 5 1
A setSQLLogger() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL;
6
7
use Doctrine\Common\Cache\Cache;
8
use Doctrine\DBAL\Logging\NullLogger;
9
use Doctrine\DBAL\Logging\SQLLogger;
10
11
/**
12
 * Configuration container for the Doctrine DBAL.
13
 *
14
 * @internal When adding a new configuration option just write a getter/setter
15
 *           pair and add the option to the _attributes array with a proper default value.
16
 */
17
class Configuration
18
{
19
    /**
20
     * The attributes that are contained in the configuration.
21
     * Values are default values.
22
     *
23
     * @var mixed[]
24
     */
25
    protected $_attributes = [];
26
27
    /**
28
     * Sets the SQL logger to use.
29
     */
30
    public function setSQLLogger(?SQLLogger $logger) : void
31
    {
32 10312
        $this->_attributes['sqlLogger'] = $logger;
33
    }
34 10312
35 10312
    /**
36
     * Gets the SQL logger that is used.
37
     */
38
    public function getSQLLogger() : SQLLogger
39
    {
40 10302
        return $this->_attributes['sqlLogger'] ?? $this->_attributes['sqlLogger'] = new NullLogger();
41
    }
42 10302
43
    /**
44
     * Gets the cache driver implementation that is used for query result caching.
45
     */
46
    public function getResultCacheImpl() : ?Cache
47
    {
48 270
        return $this->_attributes['resultCacheImpl'] ?? null;
49
    }
50 270
51
    /**
52
     * Sets the cache driver implementation that is used for query result caching.
53
     */
54
    public function setResultCacheImpl(Cache $cacheImpl) : void
55
    {
56 324
        $this->_attributes['resultCacheImpl'] = $cacheImpl;
57
    }
58 324
59 324
    /**
60
     * Sets the callable to use to filter schema assets.
61
     */
62
    public function setSchemaAssetsFilter(?callable $callable = null) : ?callable
63
    {
64
        $this->_attributes['filterSchemaAssetsExpression'] = null;
65
66
        return $this->_attributes['filterSchemaAssetsExpressionCallable'] = $callable;
67
    }
68
69
    /**
70
     * Returns the callable to use to filter schema assets.
71
     */
72
    public function getSchemaAssetsFilter() : ?callable
73
    {
74
        return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null;
75
    }
76
77
    /**
78
     * Sets the default auto-commit mode for connections.
79
     *
80
     * If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual
81
     * transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either
82
     * the method commit or the method rollback. By default, new connections are in auto-commit mode.
83
     *
84
     * @see getAutoCommit
85
     *
86
     * @param bool $autoCommit True to enable auto-commit mode; false to disable it.
87
     */
88
    public function setAutoCommit(bool $autoCommit) : void
89
    {
90
        $this->_attributes['autoCommit'] = $autoCommit;
91
    }
92
93
    /**
94 380
     * Returns the default auto-commit mode for connections.
95
     *
96 380
     * @see    setAutoCommit
97
     *
98 380
     * @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
99
     */
100
    public function getAutoCommit() : bool
101
    {
102
        return $this->_attributes['autoCommit'] ?? true;
103
    }
104
}
105