Conditions | 1 |
Paths | 1 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public static function make(array $configs): PDOConnector |
||
15 | { |
||
16 | $driver = $configs['driver']; |
||
17 | $host = $configs['host'] ?? '127.0.0.1'; |
||
18 | $username = $configs['username']; |
||
19 | $password = $configs['password']; |
||
20 | |||
21 | $host = "$driver:host=$host"; |
||
22 | $pdo = new PDO($host, $username, $password); |
||
23 | |||
24 | return new static($pdo); |
||
25 | } |
||
26 | |||
38 |
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: