MessagesCatalogue   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 19
cts 20
cp 0.95
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadDomain() 0 3 1
B loadTexts() 0 24 5
A getLanguageFilenameMask() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Translation\Loaders;
5
6
use Nette\Utils\Finder,
7
    Nexendrie\Translation\FolderNotSetException;
8
9
/**
10
 * MessagesCatalogue
11
 * Loads texts from compiled (PHP) messages catalogue
12
 *
13
 * @author Jakub Konečný
14
 */
15 1
class MessagesCatalogue extends PhpLoader {
16
  protected function loadDomain(string $name): array {
0 ignored issues
show
Unused Code introduced by Jakub Konečný
The method parameter $name is never used
Loading history...
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
17
    return [];
18
  }
19
  
20
  protected function loadTexts(): void {
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
21 1
    if(!count($this->folders)) {
22 1
      throw new FolderNotSetException("Folder for translations was not set.");
23
    }
24 1
    $this->resources = $texts = [];
25 1
    $filename = str_replace("*", $this->lang, $this->getLanguageFilenameMask());
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
26 1
    $files = Finder::findFiles($filename)
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
27 1
      ->from($this->folders);
28
    /** @var \SplFileInfo $file */
29 1
    foreach($files as $file) {
30 1
      $texts = array_merge($texts, $this->parseFile($file->getPathname()));
31 1
      if(isset($texts["__resources"])) {
32 1
        $this->resources = array_merge($this->resources, $texts["__resources"]);
33 1
        unset($texts["__resources"]);
34
      } else {
35 1
        $domains = array_keys($texts);
36 1
        foreach($domains as $domain) {
37 1
          $this->addResource($file->getPathname(), $domain);
38
        }
39
      }
40
    }
41 1
    $this->texts = $texts;
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
42 1
    $this->loadedLang = $this->lang;
43 1
  }
44
  
45
  protected function getLanguageFilenameMask(): string {
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
46 1
    return "catalogue.*.$this->extension";
47
  }
48
}
49
?>