BaseChatCommand::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
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
{
14
    use \Nette\SmartObject;
15
16
    protected string $name = "";
17
18
    /**
19
     * Defines default name for the chat command
20
     * The class' name has to follow XCommand pattern
21
     */
22
    public function getName(): string
23
    {
24 1
        if ($this->name !== "") {
25 1
            return $this->name;
26
        }
27 1
        $className = join('', array_slice(explode('\\', static::class), -1));
28 1
        return strtolower(str_replace("Command", "", $className));
29
    }
30
31
    public function setName(string $name): void
32
    {
33 1
        $this->name = $name;
34 1
    }
35
}
36