BaseChatCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 2 1
A getName() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
namespace HeroesofAbenez\Chat;
5
6
/**
7
 * Base chat Command
8
 *
9
 * @author Jakub Konečný
10
 * @property string $name
11
 */
12 1
abstract class BaseChatCommand implements IChatCommand {
13
  use \Nette\SmartObject;
14
15
  protected string $name = "";
16
  
17
  /**
18
   * Defines default name for the chat command
19
   * The class' name has to follow XCommand pattern
20
   */
21
  public function getName(): string {
22 1
    if($this->name !== "") {
23 1
      return $this->name;
24
    }
25 1
    $className = join('', array_slice(explode('\\', static::class), -1));
26 1
    return strtolower(str_replace("Command", "", $className));
27
  }
28
  
29
  public function setName(string $name): void {
30 1
    $this->name = $name;
31 1
  }
32
}
33
?>