CatalogueCompiler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 16
cts 16
cp 1
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A compile() 0 12 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Translation;
5
6
use Nexendrie\Translation\Loaders\ILoader,
7
    Nette\PhpGenerator\Helpers,
8
    Nette\Utils\FileSystem;
9
10
/**
11
 * CatalogueCompiler
12
 * Compiles messages catalogues from resources found by loader
13
 *
14
 * @author Jakub Konečný
15
 */
16 1
class CatalogueCompiler {
17 1
  use \Nette\SmartObject;
18
  
19
  /** @var ILoader */
20
  protected $loader;
21
  /** @var string[] */
22
  protected $languages = [];
23
  /** @var string */
24
  protected $folder = "";
25
  
26
  /**
27
   * @param ILoader $loader
28
   * @param string $folder
29
   * @param string[] $languages
30
   */
31
  public function __construct(ILoader $loader, string $folder, array $languages = []) {
32 1
    $this->loader = $loader;
33 1
    if(!count($languages)) {
34 1
      $languages = $loader->getAvailableLanguages();
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Consider using a different name than the parameter $languages. This often makes code more readable.
Loading history...
35
    }
36 1
    $this->languages = $languages;
37 1
    $this->folder = $folder;
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 4 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...
38 1
  }
39
  
40
  /**
41
   * Compile catalogues
42
   */
43
  public function compile(): void {
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Expected 1 space after closing parenthesis; found 0
Loading history...
44 1
    foreach($this->languages as $language) {
45 1
      $this->loader->setLang($language);
46 1
      $texts = $this->loader->getTexts();
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 16 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...
47 1
      $texts["__resources"] = $this->loader->getResources();
48
      $content = "<?php
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 14 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...
49 1
return " . Helpers::dump($texts) . ";
50
?>";
51 1
      $filename = $this->folder . "/catalogue.$language.php";
0 ignored issues
show
Coding Style introduced by Jakub Konečný
Equals sign not aligned with surrounding assignments; expected 13 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...
52 1
      FileSystem::write($filename, $content);
53
    }
54 1
  }
55
}
56
?>