| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function getTitle() |
||
| 27 | { |
||
| 28 | $html = $this->httpClient->get($this->url); |
||
|
|
|||
| 29 | |||
| 30 | if (preg_match('/<title>(.*)<\/title>/siU', $html, $matches)) { |
||
| 31 | return trim($matches[1]); |
||
| 32 | } |
||
| 33 | |||
| 34 | $components = parse_url($this->url); |
||
| 35 | |||
| 36 | if (!empty($components['host']) && !empty($components['path'])) { |
||
| 37 | return $components['host'].$components['path']; |
||
| 38 | } |
||
| 39 | |||
| 40 | return t('Title not found'); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.