LinkRenderPresenterAction   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
eloc 13
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A renderLink() 0 5 2
A __construct() 0 2 1
A isApplicable() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Menu;
5
6
use Nette\Application\LinkGenerator;
7
use Nette\Application\UI\InvalidLinkException;
8
9
/**
10
 * LinkRenderPresenterAction
11
 *
12
 * @author Jakub Konečný
13
 */
14 1
final class LinkRenderPresenterAction extends BaseLinkRender {
15
  protected string $name = "presenterAction";
16
17
  private LinkGenerator $linkGenerator;
18
  
19
  public function __construct(LinkGenerator $linkGenerator) {
20 1
    $this->linkGenerator = $linkGenerator;
21 1
  }
22
  
23
  public function isApplicable(string $link): bool {
24
    try {
25 1
      $this->linkGenerator->link($link);
26 1
      return true;
27 1
    } catch(InvalidLinkException $e) {
28 1
      return false;
29
    }
30
  }
31
  
32
  public function renderLink(string $link): string {
33
    try {
34 1
      return $this->linkGenerator->link($link);
35 1
    } catch(InvalidLinkException $e) {
36 1
      return "";
37
    }
38
  }
39
}
40
?>