| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 37 | public function getUserAgent() |
||
| 38 | { |
||
| 39 | $this->parseIniFiles(); |
||
| 40 | |||
| 41 | $randBrowser = $this->browser[rand(0, count($this->browser) - 1)]; |
||
| 42 | $randSystem = $this->system[rand(0, count($this->system) - 1)]; |
||
| 43 | $randLocale = $this->locale[rand(0, count($this->locale) - 1)]; |
||
| 44 | |||
| 45 | $format = '%s/%d.%d (%s %d.%d; %s;)'; |
||
| 46 | |||
| 47 | $userAgent = sprintf( |
||
| 48 | $format, |
||
| 49 | $randBrowser, |
||
| 50 | rand(1, 20), |
||
| 51 | rand(0, 20), |
||
| 52 | $randSystem, |
||
| 53 | rand(1, 7), |
||
| 54 | rand(0, 9), |
||
| 55 | $randLocale |
||
| 56 | ); |
||
| 57 | |||
| 58 | return ['User-Agent' => $userAgent]; |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.