| Total Complexity | 11 |
| Total Lines | 101 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class Connector |
||
| 8 | { |
||
| 9 | protected string $driver; |
||
| 10 | protected array $connectionParameters = []; |
||
| 11 | |||
| 12 | protected string $user; |
||
| 13 | protected string $password; |
||
| 14 | protected string $host; |
||
| 15 | protected int $port; |
||
| 16 | protected string $dbName; |
||
| 17 | |||
| 18 | public abstract function connect () : Connection; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return string |
||
| 22 | */ |
||
| 23 | public function getDriver () : string |
||
| 24 | { |
||
| 25 | return $this->driver; |
||
| 26 | } |
||
| 27 | |||
| 28 | protected abstract function getConnectionParameters () : array; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | public function getUser () : string |
||
| 34 | { |
||
| 35 | return $this->user; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string $user |
||
| 40 | */ |
||
| 41 | public function setUser ( string $user ) : void |
||
| 42 | { |
||
| 43 | $this->user = $user; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | public function getPassword () : string |
||
| 50 | { |
||
| 51 | return $this->password; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param string $password |
||
| 56 | */ |
||
| 57 | public function setPassword ( string $password ) : void |
||
| 58 | { |
||
| 59 | $this->password = $password; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | public function getHost () : string |
||
| 66 | { |
||
| 67 | return $this->host; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $host |
||
| 72 | */ |
||
| 73 | public function setHost ( string $host ) : void |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return int |
||
| 80 | */ |
||
| 81 | public function getPort () : int |
||
| 82 | { |
||
| 83 | return $this->port; |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @param int $port |
||
| 88 | */ |
||
| 89 | public function setPort ( int $port ) : void |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function getDbName () : string |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param string $dbName |
||
| 104 | */ |
||
| 105 | public function setDbName ( string $dbName ) : void |
||
| 110 |