CommitCommand::addFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 getAddremove()
21
 * @method void setAddremove(boolean $flag)
22
 * @method boolean getCloseBranch()
23
 * @method void setCloseBranch(boolean $flag)
24
 * @method boolean getAmend()
25
 * @method void setAmend(boolean $flag)
26
 * @method boolean getSecret()
27
 * @method void setSecret(boolean $flag)
28
 * @method boolean getEdit()
29
 * @method void setEdit(boolean $flag)
30
 * @method array getInclude()
31
 * @method void addInclude(string $pattern)
32
 * @method array getExclude()
33
 * @method void addExclude(string $pattern)
34
 * @method string getMessage()
35
 * @method void setMessage(string $text)
36
 * @method string getLogfile()
37
 * @method void setLogfile(string $file)
38
 * @method string getDate()
39
 * @method void setDate(string $date)
40
 * @method string getUser()
41
 * @method void setUser(string $user)
42
 * @method boolean getSubrepos()
43
 * @method void setSubrepos(boolean $flag)
44
 */
45
class CommitCommand extends AbstractCommand
46
{
47
    /**
48
     * Available arguments for this command.
49
     *
50
     * @var array $arguments
51
     */
52
    protected $arguments = [
53
        'file' => []
54
    ];
55
56
    /**
57
     * {@inheritdoc}
58
     *
59
     * @var mixed $options
60
     */
61
    protected $options = [
62
        '--addremove'    => false,
63
        '--close-branch' => false,
64
        '--amend'        => false,
65
        '--secret'       => false,
66
        '--edit'         => false,
67
        '--include'      => [],
68
        '--exclude'      => [],
69
        '--message'      => '',
70
        '--logfile'      => '',
71
        '--date'         => '',
72
        '--user'         => '',
73
        '--subrepos'     => false
74
    ];
75
76
    /**
77
     * @return array
78
     */
79 1
    public function getFile()
80
    {
81 1
        return $this->arguments['file'];
82
    }
83
84
    /**
85
     * @param string $file
86
     *
87
     * @return void
88
     */
89 1
    public function addFile($file)
90
    {
91 1
        $this->arguments['file'][] = escapeshellarg($file);
92 1
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97 1
    public function __toString()
98
    {
99 1
        return sprintf(
100 1
            "%s%s %s",
101 1
            $this->name,
102 1
            $this->assembleOptionString(),
103 1
            implode(' ', $this->arguments['file'])
104
        );
105
    }
106
}
107