Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | protected function getDsnParts() |
||
35 | { |
||
36 | $colonPosition = strrpos($this->dsn, ':'); |
||
37 | |||
38 | if ($colonPosition === false) { |
||
39 | $host = $this->dsn; |
||
40 | $port = ''; |
||
41 | } else { |
||
42 | $host = substr($this->dsn, 0, $colonPosition); |
||
43 | $port = substr($this->dsn, $colonPosition + 1); |
||
44 | } |
||
45 | |||
46 | return [ |
||
47 | 'host' => $host, |
||
48 | 'port' => $port |
||
49 | ]; |
||
50 | } |
||
51 | } |
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: