Completed
Push — master ( bfece9...22f2d6 )
by Kristof
28:03 queued 20:52
created

DBALPurgeService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A purgeAll() 0 6 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
        $platform = $this->connection->getDatabasePlatform();
40
        $sql = $platform->getTruncateTableSQL($this->tableName);
41
        $this->connection->exec($sql);
42
    }
43
}
44