Passed
Pull Request — master (#40)
by
unknown
02:04
created

Command::getHandlerStack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace GuzzleHttp\Command;
3
4
use GuzzleHttp\HandlerStack;
5
6
/**
7
 * Default command implementation.
8
 */
9
class Command implements CommandInterface
10
{
11
    use HasDataTrait;
12
13
    /** @var string */
14
    private $name;
15
16
    /** @var HandlerStack */
17
    private $handlerStack;
18
19
    /**
20
     * @param string       $name         Name of the command
21
     * @param array        $args         Arguments to pass to the command
22
     * @param HandlerStack $handlerStack Stack of middleware for the command
23
     */
24
    public function __construct(
25
        $name,
26
        array $args = [],
27
        HandlerStack $handlerStack = null
28
    ) {
29
        $this->name = $name;
30
        $this->data = $args;
31
        $this->handlerStack = $handlerStack;
32
    }
33
34
    public function getHandlerStack()
35
    {
36
        return $this->handlerStack;
37
    }
38
39
    public function getName()
40
    {
41
        return $this->name;
42
    }
43
44
    public function hasParam($name)
45
    {
46
        return array_key_exists($name, $this->data);
47
    }
48
49
    public function __clone()
50
    {
51
        if ($this->handlerStack) {
52
            $this->handlerStack = clone $this->handlerStack;
53
        }
54
    }
55
}
56