ChainLocaleResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addResolver() 0 3 1
A resolve() 0 9 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Translation\Resolvers;
5
6
use Nexendrie\Utils\Collection;
7
8
/**
9
 * ChainResolver
10
 *
11
 * @author Jakub Konečný
12
 */
13 1
class ChainLocaleResolver extends Collection implements ILocaleResolver {
14 1
  use \Nette\SmartObject;
15
  
16
  protected $class = ILocaleResolver::class;
17
  
18
  public function addResolver(ILocaleResolver $resolver): void {
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
19 1
    $this[] = $resolver;
20 1
  }
21
  
22
  public function resolve(): ?string {
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
Coding Style introduced by Jakub Konečný
Inline shorthand IF statement must be declared on a single line
Loading history...
23 1
    foreach($this as $resolver) {
24 1
      $lang = $resolver->resolve();
25 1
      if(!is_null($lang)) {
26 1
        return $lang;
27
      }
28
    }
29 1
    return NULL;
30
  }
31
}
32
?>