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

DBALPurgeService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 2
c 4
b 1
f 1
lcom 1
cbo 2
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A purgeAll() 0 5 1
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