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

BaseLinkRender::getName()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 5
nop 0
crap 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 View Code Duplication
abstract class BaseLinkRender implements IMenuItemLinkRender {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15 1
  use \Nette\SmartObject;
16
  
17
  public function getName(): string {
18 1
    $reflection = new \ReflectionClass($this);
19 1
    if($reflection->hasProperty("name")) {
20 1
      if(is_string($this->name)) {
21 1
        return $this->name;
22
      }
23
    }
24 1
    $class = Strings::after(static::class, "\\", -1);
25 1
    if(Strings::startsWith($class, "LinkRender")) {
26 1
      $class = Strings::after($class, "LinkRender");
27
    }
28 1
    return Strings::lower($class);
29
  }
30
}
31
?>