LinkRenderPresenterAction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
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
?>