QueueCommand::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace League\Tactician\Bernard;
4
5
/**
6
 * Wraps any command to be queueable
7
 */
8
final class QueueCommand implements QueueableCommand
9
{
10
    /**
11
     * @var object
12
     */
13
    private $command;
14
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @param object      $command
22
     * @param string|null $name
23
     */
24 8
    public function __construct($command, $name = null)
25
    {
26 8
        $this->command = $command;
27
28 8
        if (is_null($name)) {
29 5
            $className = get_class($command);
30 5
            $name = substr($className, strrpos($className, '\\') + 1);
31 5
        }
32
33 8
        $this->name = $name;
34 8
    }
35
36
    /**
37
     * Returns the wrapped command
38
     *
39
     * @return object
40
     */
41 4
    public function getCommand()
42
    {
43 4
        return $this->command;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 4
    public function getName()
50
    {
51 4
        return $this->name;
52
    }
53
}
54