Completed
Pull Request — master (#130)
by Kristof
12:25 queued 04:18
created

DBALPurgeService::purgeAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
dl 0
loc 6
rs 9.4285
c 4
b 0
f 1
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Storage;
4
5
use Doctrine\DBAL\Connection;
6
7
/**
8
 * Class DBALPurgeService
9
 * @package CultuurNet\UDB3\Storage
10
 */
11
class DBALPurgeService implements PurgeServiceInterface
12
{
13
    /**
14
     * @var Connection
15
     */
16
    private $connection;
17
18
    /**
19
     * @var string
20
     */
21
    private $tableName;
22
23
    /**
24
     * DBALPurgeService constructor.
25
     * @param Connection $connection
26
     * @param string $tableName
27
     */
28
    public function __construct(
29
        $connection,
30
        $tableName
31
    ) {
32
        $this->connection = $connection;
33
34
        $this->tableName = $tableName;
35
    }
36
37
    public function purgeAll()
38
    {
39
        $platform = $this->connection->getDatabasePlatform();
40
        $sql = $platform->getTruncateTableSQL($this->tableName);
41
        $this->connection->exec($sql);
42
    }
43
}
44