TranslationPanel   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
eloc 17
c 2
b 0
f 1
dl 0
loc 32
rs 10
ccs 15
cts 16
cp 0.9375

4 Methods

Rating   Name   Duplication   Size   Complexity  
A renderLink() 0 5 2
A __construct() 0 3 1
A getTab() 0 5 1
A getPanel() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Translation\Bridges\Tracy;
5
6
use Nexendrie\Translation\ILoader;
7
use Nexendrie\Translation\Translator;
8
use Tracy\IBarPanel;
9
10
/**
11
 * Debugger panel for Tracy
12
 *
13
 * @author Jakub Konečný
14
 */
15 1
final class TranslationPanel implements IBarPanel {
16
  /** @var Translator */
17
  protected $translator;
18
  /** @var ILoader */
19
  protected $loader;
20
  
21
  public function __construct(Translator $translator, ILoader $loader) {
22 1
    $this->translator = $translator;
23 1
    $this->loader = $loader;
24 1
  }
25
  
26
  public function getTab(): string {
27 1
    $lang = $this->loader->getLang();
28
    /** @var string $tab */
29 1
    $tab = file_get_contents(__DIR__ . "/TranslationPanel.tab.html");
30 1
    return str_replace("%lang%", $lang, $tab);
31
  }
32
  
33
  public function getPanel(): string {
34 1
    $loader = $this->loader;
35 1
    $translator = $this->translator;
36 1
    $resourcesCount = count($loader->getResources(), COUNT_RECURSIVE) - count($loader->getResources());
37 1
    ob_start();
38 1
    require __DIR__ . "/TranslationPanel.panel.phtml";
39 1
    return ob_get_clean();
40
  }
41
  
42
  protected function renderLink(string $resource): string {
43 1
    if(is_file($resource)) {
44 1
      return \Tracy\Helpers::editorLink($resource);
45
    }
46
    return $resource;
47
  }
48
}
49
?>