Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function __construct(PDO $pdo) |
||
16 | { |
||
17 | $engine = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); |
||
18 | |||
19 | switch ($engine) { |
||
20 | case 'mysql': |
||
21 | $this->scheme = new Mysql($pdo); |
||
|
|||
22 | break; |
||
23 | case 'sqlite': |
||
24 | $this->scheme = new Sqlite($pdo); |
||
25 | break; |
||
26 | default: |
||
27 | throw new RuntimeException(sprintf('Invalid engine type: %s', $engine)); |
||
28 | } |
||
29 | } |
||
30 | |||
41 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: