Conditions | 3 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function overrideSubDomain($subDomain, $url = null) |
||
34 | { |
||
35 | $url = ($url) ? : $this->baseUrl; |
||
|
|||
36 | |||
37 | $info = parse_url($url); |
||
38 | |||
39 | $array = explode('.', $info['host']); |
||
40 | |||
41 | $withoutDomain = (array_key_exists(count($array) - 2, |
||
42 | $array) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1]; |
||
43 | |||
44 | $newSubDomain = $info['scheme'] . '://' . $subDomain . '.' . $withoutDomain; |
||
45 | |||
46 | $this->baseUrl = $newSubDomain; |
||
47 | } |
||
48 | |||
50 |
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: