AbstractSchemaSynchronizer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A processSqlSafely() 0 6 3
A __construct() 0 3 1
A processSql() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Schema\Synchronizer;
6
7
use Doctrine\DBAL\Connection;
8
use Throwable;
9
10
/**
11
 * Abstract schema synchronizer with methods for executing batches of SQL.
12
 */
13
abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
14
{
15
    /** @var Connection */
16
    protected $conn;
17
18 88
    public function __construct(Connection $conn)
19
    {
20 88
        $this->conn = $conn;
21 88
    }
22
23
    /**
24
     * @param array<int, string> $sql
25
     */
26
    protected function processSqlSafely(array $sql) : void
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 array<int, string> $sql
38
     */
39 44
    protected function processSql(array $sql) : void
40
    {
41 44
        foreach ($sql as $s) {
42 44
            $this->conn->exec($s);
43
        }
44 44
    }
45
}
46