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

DatabaseUtil   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 31
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A query() 0 6 2
A getName() 0 3 1
A getExtraArguments() 0 3 1
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