Passed
Pull Request — master (#249)
by Wilmer
02:57
created

MysqlHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
c 1
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createConnection() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Support;
6
7
use Yiisoft\Db\Connection\ConnectionInterface;
8
use Yiisoft\Db\Mysql\ConnectionPDO;
9
use Yiisoft\Db\Mysql\PDODriver;
10
11
final class MysqlHelper extends ConnectionHelper
12
{
13
    private string $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;port=3306';
14
    private string $username = 'root';
15
    private string $password = '';
16
    private string $charset = 'UTF8MB4';
17
18
    public function createConnection(): ConnectionInterface
19
    {
20
        $pdoDriver = new PDODriver($this->dsn, $this->username, $this->password);
21
        $pdoDriver->charset($this->charset);
22
23
        return new ConnectionPDO($pdoDriver, $this->createSchemaCache());
24
    }
25
}
26