Completed
Pull Request — master (#9)
by Sander
04:49
created

DatabaseUtil::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Edyan\Neuralyzer\ExpressionUtils;
4
5
use Doctrine\DBAL\Connection;
6
use Edyan\Neuralyzer\Exception\NeuralizerException;
7
8
/**
9
 * Class DatabaseUtil
10
 */
11
class DatabaseUtil implements UtilsInterface
12
{
13
    /**
14
     * @var Connection
15
     */
16
    public $conn;
17
18
    /**
19
     * @return string
20
     */
21
    public function getName(): string
22
    {
23
        return 'db';
24
    }
25
26
    public function getExtraArguments(): array
27
    {
28
        return ['conn'];
29
    }
30
31
    /**
32
     * @param string $sql
33
     *
34
     * @throws NeuralizerException
35
     */
36
    public function query(string $sql)
37
    {
38
        try {
39
            $this->conn->query($sql);
40
        } catch (\Exception $e) {
41
            throw new NeuralizerException($e->getMessage());
42
        }
43
    }
44
}
45