BaseChatCommand::setName()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 2
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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
?>