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

Command   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 47
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getHandlerStack() 0 4 1
A getName() 0 4 1
A hasParam() 0 4 1
A __clone() 0 6 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