Passed
Push — master ( bbf0da...682cd1 )
by Emmanuel
02:36
created

AbstractDBHelper::getEnclosureForCSV()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
    public function __construct(Connection $conn)
44
    {
45
        $this->conn = $conn;
46
    }
47
48
    /**
49
     * Set Pretend to true to simulate queries, false to execute interface
50
     * @param bool $pretend
51
     */
52
    public function setPretend(bool $pretend)
53
    {
54
        $this->pretend = $pretend;
55
    }
56
57
    /**
58
     * Get, for a driver options for connection (PDO)
59
     * @return array
60
     */
61
    public static function getDriverOptions(): array
62
    {
63
        return [];
64
    }
65
66
    /**
67
     * Set the right enclosure
68
     * @return string
69
     */
70
    public function getEnclosureForCSV(): string
71
    {
72
        return '"';
73
    }
74
75
76
    /**
77
     * Load Data from a CSV
78
     * @param  string  $table
79
     * @param  string  $filename
80
     * @param  array   $fields
81
     * @param  string  $mode  Not in used here
82
     * @return string
83
     */
84
    abstract public function loadData(
85
        string $table,
86
        string $filename,
87
        array $fields,
88
        string $mode
89
    ): string;
90
}
91