| Total Complexity | 4 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| 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 | public function __construct(string $dbname, array $params) |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * connect to db |
||
| 34 | * |
||
| 35 | * @return void |
||
| 36 | */ |
||
| 37 | public function connect() |
||
| 38 | { |
||
| 39 | $this->connection = new PDO( |
||
| 40 | $this->dsn(), |
||
| 41 | $this->username, |
||
| 42 | $this->password, |
||
| 43 | $this->options |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * return PDO instance |
||
| 49 | * |
||
| 50 | * @return PDO |
||
| 51 | */ |
||
| 52 | public function getConnection(): PDO |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * return dsn |
||
| 59 | * |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | protected function dsn(): string |
||
| 68 | ); |
||
| 69 | } |
||
| 71 |