Passed
Push — master ( becae5...2d4555 )
by Jean Paul
12:24
created

MySqlConnector::executeExtraStatements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Coco\SourceWatcher\Core\Database\Connections;
4
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\Exception;
7
8
/**
9
 * Class MySqlConnector
10
 *
11
 * @package Coco\SourceWatcher\Core\Database\Connections
12
 *
13
 * Following the definition from:
14
 *     https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#pdo-mysql
15
 */
16
class MySqlConnector extends ClientServerDatabaseConnector
17
{
18
    protected string $unixSocket = "";
19
20
    protected string $charset = "";
21
22
    public function __construct ()
23
    {
24
        parent::__construct();
25
26
        $this->driver = "pdo_mysql";
27
28
        $this->port = 3306;
29
    }
30
31
    public function getUnixSocket () : string
32
    {
33
        return $this->unixSocket;
34
    }
35
36
    public function setUnixSocket ( string $unixSocket ) : void
37
    {
38
        $this->unixSocket = $unixSocket;
39
    }
40
41
    public function getCharset () : string
42
    {
43
        return $this->charset;
44
    }
45
46
    public function setCharset ( string $charset ) : void
47
    {
48
        $this->charset = $charset;
49
    }
50
51
    public function getConnectionParameters () : array
52
    {
53
        $this->extraParameters = [ "unix_socket" => $this->unixSocket, "charset" => $this->charset ];
54
55
        return parent::getConnectionParameters();
56
    }
57
58
    /**
59
     * @throws Exception
60
     */
61
    public function executeExtraStatements (Connection $connection) : void {
62
        $connection->executeStatement( "SET SESSION wait_timeout = 3600;" );
63
    }
64
}
65