LocateCommand::addPattern()   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 string getRev()
21
 * @method void setRev(string $revision)
22
 * @method boolean getPrint0()
23
 * @method void setPrint0(boolean $flag)
24
 * @method boolean getFullpath()
25
 * @method void setFullpath(boolean $flag)
26
 * @method array getInclude()
27
 * @method void addInclude(string $pattern)
28
 * @method array getExclude()
29
 * @method void addExclude(string $pattern)
30
 */
31
class LocateCommand extends AbstractCommand
32
{
33
    /**
34
     * Available arguments for this command.
35
     *
36
     * @var array $arguments
37
     */
38
    protected $arguments = [
39
        'pattern' => []
40
    ];
41
42
    /**
43
     * {@inheritdoc}
44
     *
45
     * @var mixed $options
46
     */
47
    protected $options = [
48
        '--rev'       => '',
49
        '--print0'    => false,
50
        '--fullpath'  => false,
51
        '--include'   => [],
52
        '--exclude'   => []
53
    ];
54
55
    /**
56
     * Get pattern arguments.
57
     *
58
     * @return array
59
     */
60 1
    public function getPattern()
61
    {
62 1
        return $this->arguments['pattern'];
63
    }
64
65
    /**
66
     * Add pattern to arguments.
67
     *
68
     * @param string $pattern
69
     *
70
     * @return void
71
     */
72 1
    public function addPattern($pattern)
73
    {
74 1
        $this->arguments['pattern'][] = escapeshellarg($pattern);
75 1
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function __toString()
81
    {
82 1
        return sprintf(
83 1
            "%s%s %s",
84 1
            $this->name,
85 1
            $this->assembleOptionString(),
86 1
            implode(' ', $this->arguments['pattern'])
87
        );
88
    }
89
}
90