Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php  | 
            ||
| 8 | class OsDetector extends AbstractDetection  | 
            ||
| 9 | { | 
            ||
| 10 | public function detect(string $ua)  | 
            ||
| 17 | |||
| 18 | protected function setupResultObject()  | 
            ||
| 29 | |||
| 30 | private function detectByFamily(): array  | 
            ||
| 43 | |||
| 44 | View Code Duplication | private function detectByDeviceType($family): array  | 
            |
| 54 | |||
| 55 | }  | 
            
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.