| Total Complexity | 4 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class PdoMysql |
||
| 10 | { |
||
| 11 | |||
| 12 | private $host; |
||
| 13 | private $dbname; |
||
| 14 | private $username; |
||
| 15 | private $password; |
||
| 16 | private $options; |
||
| 17 | private $connection; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * instanciate |
||
| 21 | * |
||
| 22 | * @param string $dbname |
||
| 23 | * @param array $params |
||
| 24 | */ |
||
| 25 | 4 | public function __construct(string $dbname, array $params) |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * connect to db |
||
| 36 | * |
||
| 37 | * @return PdoMysql |
||
| 38 | */ |
||
| 39 | 2 | public function connect(): PdoMysql |
|
| 40 | { |
||
| 41 | 2 | $this->connection = new PDO( |
|
| 42 | 2 | $this->dsn(), |
|
| 43 | 2 | $this->username, |
|
| 44 | 2 | $this->password, |
|
| 45 | 2 | $this->options |
|
| 46 | ); |
||
| 47 | 2 | return $this; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * return PDO instance |
||
| 52 | * |
||
| 53 | * @return PDO |
||
| 54 | */ |
||
| 55 | 1 | public function getConnection(): PDO |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * return dsn |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 1 | protected function dsn(): string |
|
| 71 | ); |
||
| 72 | } |
||
| 74 |