Conditions | 10 |
Paths | 15 |
Total Lines | 34 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
26 | private function runMultiLanguage(): void |
||
27 | { |
||
28 | // check if multi-language is enabled |
||
29 | if (!App::$Properties->get('multiLanguage')) { |
||
30 | $this->language = App::$Properties->get('singleLanguage'); |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | // check if domain-lang binding is enabled |
||
35 | if (Any::isArray(App::$Properties->get('languageDomainAlias'))) { |
||
36 | /** @var array $domainAlias */ |
||
37 | $domainAlias = App::$Properties->get('languageDomainAlias'); |
||
38 | if (Any::isArray($domainAlias) && !Str::likeEmpty($domainAlias[$this->getHost()])) { |
||
|
|||
39 | $this->language = $domainAlias[$this->getHost()]; |
||
40 | } |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | // try to find language in pathway |
||
45 | foreach (App::$Properties->get('languages') as $lang) { |
||
46 | if (Str::startsWith('/' . $lang, $this->getPathInfo())) { |
||
47 | $this->language = $lang; |
||
48 | $this->languageInPath = true; |
||
49 | } |
||
50 | } |
||
51 | |||
52 | // try to find in ?lang get |
||
53 | if (!$this->language && Arr::in($this->query->get('lang'), App::$Properties->get('languages'))) { |
||
54 | $this->language = $this->query->get('lang'); |
||
55 | } |
||
56 | |||
57 | // language still not defined?! |
||
58 | if (!$this->language) { |
||
59 | $this->setLanguageFromBrowser(); |
||
60 | } |
||
126 |