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

AbstractSchemaSynchronizer::processSql()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 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