Completed
Pull Request — master (#130)
by Kristof
18:57 queued 11:22
created

DBALPurgeService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
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