Completed
Push — master ( 3a3759...49115f )
by Jakub
17:00
created

LinkRenderPresenterAction   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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