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