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