StorageMysqli   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createInstance() 0 17 8
1
<?php
2
3
namespace Simplario\Checker\Checker;
4
5
class StorageMysqli extends StoragePdo
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $target = 'connect';
11
12
    /**
13
     * @param array $connect
14
     *
15
     * @return \mysqli
16
     * @throws \Exception
17
     */
18
    protected function createInstance(array $connect)
19
    {
20
        $instance = mysqli_connect(
21
            isset($connect['host']) ? $connect['host'] : '127.0.0.1',
22
            isset($connect['user']) ? $connect['user'] : '',
23
            isset($connect['password']) ? $connect['password'] : '',
24
            isset($connect['database']) ? $connect['database'] : '',
25
            isset($connect['port']) ? $connect['port'] : 3306,
26
            isset($connect['socket']) ? $connect['socket'] : ''
27
        );
28
29
        if (!$instance) {
30
            throw new \Exception("Unable to connect to MySQL. " . mysqli_connect_error());
31
        }
32
33
        return $instance;
34
    }
35
36
}
37