AddCommand::getFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
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 array getInclude()
21
 * @method void addInclude(string $pattern)
22
 * @method array getExclude()
23
 * @method void addExclude(string $pattern)
24
 * @method boolean getSubrepos()
25
 * @method void setSubrepos(boolean $flag)
26
 * @method boolean getDryRun()
27
 * @method void setDryRun(boolean $flag)
28
 */
29
class AddCommand extends AbstractCommand
30
{
31
    /**
32
     * Available arguments for this command.
33
     *
34
     * @var array $arguments
35
     */
36
    protected $arguments = [
37
        'file' => []
38
    ];
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @var mixed $options
44
     */
45
    protected $options = [
46
        '--include'  => [],
47
        '--exclude'  => [],
48
        '--subrepos' => false,
49
        '--dry-run'  => false
50
    ];
51
52
    /**
53
     * Get the file argument.
54
     *
55
     * @return array
56
     */
57 1
    public function getFile()
58
    {
59 1
        return $this->arguments['file'];
60
    }
61
62
    /**
63
     * Add a file to the file argument.
64
     *
65
     * @param string $file
66
     *
67
     * @return void
68
     */
69 1
    public function addFile($file)
70
    {
71 1
        $this->arguments['file'][] = escapeshellarg($file);
72 1
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 1
    public function __toString()
78
    {
79 1
        return sprintf(
80 1
            "%s%s %s",
81 1
            $this->name,
82 1
            $this->assembleOptionString(),
83 1
            implode(' ', $this->arguments['file'])
84
        );
85
    }
86
}
87