Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class LocaleInPreferredBrowserLanguage implements LocaleDetector |
||
9 | { |
||
10 | /** |
||
11 | * @param Request $request |
||
12 | * @param Locale $locale |
||
13 | * |
||
14 | * @return bool |
||
15 | */ |
||
16 | public function match(Request $request, Locale $locale): bool |
||
17 | { |
||
18 | return ! empty($this->detectPreferredLanguage()); |
||
|
|||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @param Request $request |
||
23 | * @param Locale $locale |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function get(Request $request, Locale $locale): string |
||
28 | { |
||
29 | return $this->detectPreferredLanguage(); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param Request $request |
||
34 | * @param Locale $locale |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | public function detectPreferredLanguage(Request $request, Locale $locale): string |
||
41 | } |
||
42 | } |
||
43 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.