BranchCommand::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * VersionControl_HG
4
 * Simple OO implementation for Mercurial.
5
 *
6
 * PHP Version 5.4
7
 *
8
 * @copyright 2014 Siad Ardroumli
9
 * @license http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link http://siad007.github.io/versioncontrol_hg
11
 */
12
13
namespace Siad007\VersionControl\HG\Command;
14
15
/**
16
 * Simple OO implementation for Mercurial.
17
 *
18
 * @author Siad Ardroumli <[email protected]>
19
 *
20
 * @method boolean getForce()
21
 * @method void setForce(boolean $flag)
22
 * @method boolean getClean()
23
 * @method void setClean(boolean $flag)
24
 */
25
class BranchCommand extends AbstractCommand
26
{
27
    /**
28
     * Available arguments for this command.
29
     *
30
     * @var array $arguments
31
     */
32
    protected $arguments = [
33
        'name'        => ''
34
    ];
35
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @var mixed $options
40
     */
41
    protected $options = [
42
        '--force' => false,
43
        '--clean' => false
44
    ];
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getName()
50
    {
51 1
        return $this->arguments['name'];
52
    }
53
54
    /**
55
     * @param string $name
56
     *
57
     * @return void
58
     */
59 1
    public function setName($name)
60
    {
61 1
        $this->arguments['name'] = escapeshellarg($name);
62 1
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67 1
    public function __toString()
68
    {
69 1
        return sprintf(
70 1
            "%s%s %s",
71 1
            $this->name,
72 1
            $this->assembleOptionString(),
73 1
            $this->arguments['name']
74
        );
75
    }
76
}
77