Completed
Pull Request — 2.11.x (#3956)
by David
14:33
created

AbstractSchemaSynchronizer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 6
eloc 9
c 0
b 0
f 0
dl 0
loc 34
ccs 6
cts 11
cp 0.5455
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A processSqlSafely() 0 6 3
A processSql() 0 4 2
1
<?php
2
3
namespace Doctrine\DBAL\Schema\Synchronizer;
4
5
use Doctrine\DBAL\Connection;
6
use Throwable;
7
8
/**
9
 * Abstract schema synchronizer with methods for executing batches of SQL.
10
 */
11
abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
12
{
13
    /** @var Connection */
14
    protected $conn;
15
16 104
    public function __construct(Connection $conn)
17
    {
18 104
        $this->conn = $conn;
19 104
    }
20
21
    /**
22
     * @param string[] $sql
23
     *
24
     * @return void
25
     */
26
    protected function processSqlSafely(array $sql)
27
    {
28
        foreach ($sql as $s) {
29
            try {
30
                $this->conn->exec($s);
31
            } catch (Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
32
            }
33
        }
34
    }
35
36
    /**
37
     * @param string[] $sql
38
     *
39
     * @return void
40
     */
41 52
    protected function processSql(array $sql)
42
    {
43 52
        foreach ($sql as $s) {
44 52
            $this->conn->exec($s);
45
        }
46 52
    }
47
}
48