| Total Complexity | 4 |
| Total Lines | 107 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class PdoPgsql |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * hostname ip |
||
| 14 | * |
||
| 15 | * @var String |
||
| 16 | */ |
||
| 17 | private $host; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * port number |
||
| 21 | * |
||
| 22 | * @var integer |
||
| 23 | */ |
||
| 24 | private $port; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * database name |
||
| 28 | * |
||
| 29 | * @var String |
||
| 30 | */ |
||
| 31 | private $dbname; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * login name |
||
| 35 | * |
||
| 36 | * @var String |
||
| 37 | */ |
||
| 38 | private $username; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * password |
||
| 42 | * |
||
| 43 | * @var String |
||
| 44 | */ |
||
| 45 | |||
| 46 | private $password; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * options |
||
| 50 | * |
||
| 51 | * @var array |
||
| 52 | */ |
||
| 53 | private $options; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * connexion |
||
| 57 | * |
||
| 58 | * @var PDO |
||
| 59 | */ |
||
| 60 | private $connection; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * instanciate |
||
| 64 | * |
||
| 65 | * @param string $dbname |
||
| 66 | * @param array $params |
||
| 67 | */ |
||
| 68 | 4 | public function __construct(string $dbname, array $params) |
|
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * connect to db |
||
| 80 | * |
||
| 81 | * @return PdoPgsql |
||
| 82 | */ |
||
| 83 | 2 | public function connect(): PdoPgsql |
|
| 84 | { |
||
| 85 | 2 | $this->connection = new PDO( |
|
| 86 | 2 | $this->dsn(), |
|
| 87 | 2 | $this->username, |
|
| 88 | 2 | $this->password, |
|
| 89 | 2 | $this->options |
|
| 90 | ); |
||
| 91 | 2 | return $this; |
|
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * return PDO instance |
||
| 96 | * |
||
| 97 | * @return PDO |
||
| 98 | */ |
||
| 99 | 1 | public function getConnection(): PDO |
|
| 100 | { |
||
| 101 | 1 | return $this->connection; |
|
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * dsn |
||
| 106 | * |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | 1 | protected function dsn(): string |
|
| 116 | ); |
||
| 117 | } |
||
| 118 | } |
||
| 119 |