Passed
Push — master ( 16eb74...e2e5d8 )
by Emmanuel
02:58
created

AbstractDBHelper::getEnclosureForCSV()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * neuralyzer : Data Anonymization Library and CLI Tool
4
 *
5
 * PHP Version 7.1
6
 *
7
 * @author Emmanuel Dyan
8
 * @copyright 2018 Emmanuel Dyan
9
 *
10
 * @package edyan/neuralyzer
11
 *
12
 * @license GNU General Public License v2.0
13
 *
14
 * @link https://github.com/edyan/neuralyzer
15
 */
16
17
namespace Edyan\Neuralyzer\Helper\DB;
18
19
use Doctrine\DBAL\Connection;
20
21
/**
22
 * Various methods to help interacting with DB servers
23
 */
24
abstract class AbstractDBHelper
25
{
26
    /**
27
     * Execute (or not) queries
28
     * @var bool
29
     */
30
    public $pretend = false;
31
32
    /**
33
     * DBAL connection
34
     * @var Connection
35
     */
36
    public $conn = null;
37
38
39
    /**
40
     * Requires a connection to work
41
     * @param Connection $conn
42
     */
43 52
    public function __construct(Connection $conn)
44
    {
45 52
        $this->conn = $conn;
46 52
    }
47
48
    /**
49
     * Set Pretend to true to simulate queries, false to execute interface
50
     * @param bool $pretend
51
     */
52 10
    public function setPretend(bool $pretend)
53
    {
54 10
        $this->pretend = $pretend;
55
56 10
        return $this;
57
    }
58
59
    /**
60
     * Get, for a driver options for connection (PDO)
61
     * @return array
62
     */
63 2
    public static function getDriverOptions(): array
64
    {
65 2
        return [];
66
    }
67
68
    /**
69
     * Set the right enclosure
70
     * @return string
71
     */
72 10
    public function getEnclosureForCSV(): string
73
    {
74 10
        return '"';
75
    }
76
77
78
    /**
79
     * Load Data from a CSV
80
     * @param  string  $table
81
     * @param  string  $filename
82
     * @param  array   $fields
83
     * @param  string  $mode  Not in used here
84
     * @return string
85
     */
86
    abstract public function loadData(
87
        string $table,
88
        string $filename,
89
        array $fields,
90
        string $mode
91
    ): string;
92
}
93