Completed
Pull Request — master (#130)
by Kristof
07:56
created

DBALPurgeService::purgeAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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
        $sql = $this->connection->getDatabasePlatform()->getTruncateTableSQL($this->tableName);
40
        $this->connection->exec($sql);
41
    }
42
}
43