GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Mysql   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 72.41 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 21
loc 29
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A connect() 21 21 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Database
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\Pdo;
10
11
/**
12
 * Connection management to MySQL.
13
 *
14
 * @package Database
15
 * @author  Gjero Krsteski <[email protected]>
16
 */
17
class Mysql extends Connector
18
{
19
    /**
20
     * @param array $config
21
     *
22
     * @return \Pimf\Database
23
     */
24 View Code Duplication
    public function connect(array $config)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $dsn = "mysql:host={$config['host']};dbname={$config['database']}";
27
28
        if (isset($config['port'])) {
29
            $dsn .= ";port={$config['port']}";
30
        }
31
32
        if (isset($config['unix_socket'])) {
33
            $dsn .= ";unix_socket={$config['unix_socket']}";
34
        }
35
36
        $connection = new \Pimf\Database($dsn, $config['username'], $config['password'], $this->options($config));
37
38
        // set to UTF-8 which should be fine for most scenarios.
39
        if (isset($config['charset'])) {
40
            $connection->prepare("SET NAMES '{$config['charset']}'")->execute();
41
        }
42
43
        return $connection;
44
    }
45
}
46