BaseLinkRender   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
c 2
b 0
f 1
eloc 11
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getName() 0 12 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Menu;
5
6
use Nette\Utils\Strings;
7
8
/**
9
 * BaseLinkRender
10
 *
11
 * @author Jakub Konečný
12
 * @property-read string $name
13
 */
14 1
abstract class BaseLinkRender implements IMenuItemLinkRender {
15
  use \Nette\SmartObject;
16
17
  protected string $name;
18
  
19
  public function getName(): string {
20 1
    $reflection = new \ReflectionClass($this);
21 1
    if($reflection->hasProperty("name")) {
22 1
      if(isset($this->name)) {
23 1
        return $this->name;
24
      }
25
    }
26 1
    $class = (string) Strings::after(static::class, "\\", -1);
27 1
    if(str_starts_with($class, "LinkRender")) {
28 1
      $class = (string) Strings::after($class, "LinkRender");
29
    }
30 1
    return Strings::lower($class);
31
  }
32
}
33
?>