| 1 | <?php |
||
| 13 | abstract class Database { |
||
| 14 | |||
| 15 | /** @var \static */ |
||
| 16 | static protected $instance; |
||
| 17 | |||
| 18 | /** @var PDO */ |
||
| 19 | protected $pdo; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Cria e retorna conexao PDO |
||
| 23 | * @param string[] $dbConfig |
||
| 24 | * @return PDO |
||
| 25 | */ |
||
| 26 | abstract function connect(&$dbConfig); |
||
| 27 | |||
| 28 | /** @return PDO */ |
||
| 29 | final public function getPDO() { |
||
| 32 | |||
| 33 | /** @return static */ |
||
| 34 | final static function instance() { |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Cria uma conexão com um banco de dados |
||
| 40 | * @param string[] $dbConfig |
||
| 41 | */ |
||
| 42 | public function __construct($dbConfig) { |
||
| 51 | |||
| 52 | protected function validateConnection() { |
||
| 59 | |||
| 60 | } |
||
| 61 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.