1
<?php
2
/**
3
 * Utilise Mercurial from within Phing.
4
 *
5
 * PHP Version 5.4
6
 *
7
 * @category Tasks
8
 * @package  phing.tasks.ext
9
 * @author   Ken Guest <kguest@php.net>
10
 * @license  LGPL (see http://www.gnu.org/licenses/lgpl.html)
11
 * @link     https://github.com/kenguest/Phing-HG
12
 */
13

14
/**
15
 * Base task for integrating phing and mercurial.
16
 *
17
 * @category Tasks
18
 * @package  phing.tasks.ext.hg
19
 * @author   Ken Guest <kguest@php.net>
20
 * @license  LGPL (see http://www.gnu.org/licenses/lgpl.html)
21
 * @link     HgBaseTask.php
22
 */
23
abstract class HgBaseTask extends Task
24
{
25
    /**
26
     * Insecure argument
27
     *
28
     * @var string
29
     */
30
    protected $insecure = '';
31

32
    /**
33
     * Repository directory
34
     *
35
     * @var string
36
     */
37
    protected $repository = '';
38

39
    /**
40
     * Whether to be quiet... --quiet argument.
41
     *
42
     * @var bool
43
     */
44
    protected $quiet = false;
45

46
    /**
47
     * Username.
48
     *
49
     * @var string
50
     */
51
    protected $user = '';
52

53
    public static $factory = null;
54
    /**
55
     * Set repository attribute
56
     *
57
     * @param string $repository Repository
58
     *
59
     * @return void
60
     */
61 1
    public function setRepository($repository)
62
    {
63 1
        $this->repository = $repository;
64
    }
65

66

67
    /**
68
     * Set the quiet attribute --quiet
69
     *
70
     * @param string $quiet yes|no|true|false|1|0
71
     *
72
     * @return void
73
     */
74 0
    public function setQuiet($quiet)
75
    {
76 0
        $this->quiet = StringHelper::booleanValue($quiet);
77
    }
78

79
    /**
80
     * Get the quiet attribute value.
81
     *
82
     * @return bool
83
     */
84 1
    public function getQuiet()
85
    {
86 1
        return $this->quiet;
87
    }
88

89
    /**
90
     * Get Repository attribute/directory.
91
     *
92
     * @return string
93
     */
94 1
    public function getRepository()
95
    {
96 1
        return $this->repository;
97
    }
98

99
    /**
100
     * Set insecure attribute
101
     *
102
     * @param string $insecure 'yes', etc.
103
     *
104
     * @return void
105
     */
106 0
    public function setInsecure($insecure)
107
    {
108 0
        $this->insecure = StringHelper::booleanValue($insecure);
109
    }
110

111
    /**
112
     * Get 'insecure' attribute value. (--insecure or null)
113
     *
114
     * @return string
115
     */
116 1
    public function getInsecure()
117
    {
118 1
        return $this->insecure;
119
    }
120

121
    /**
122
     * Set user attribute
123
     *
124
     * @param string $user username/email address.
125
     *
126
     * @return void
127
     */
128 1
    public function setUser($user)
129
    {
130 1
        $this->user = $user;
131
    }
132

133
    /**
134
     * Get username attribute.
135
     *
136
     * @return string
137
     */
138 1
    public function getUser()
139
    {
140 1
        return $this->user;
141
    }
142

143
    /**
144
     * Check provided repository directory actually is an existing directory.
145
     *
146
     * @param string $dir Repository directory
147
     *
148
     * @return bool
149
     * @throws BuildException
150
     */
151 1
    public function checkRepositoryIsDirAndExists($dir)
152
    {
153 1
        if (file_exists($dir)) {
154 1
            if (!is_dir($dir)) {
155 0
                throw new BuildException("Repository '$dir' is not a directory.");
156
            }
157
        } else {
158 1
            throw new BuildException("Repository directory '$dir' does not exist.");
159
        }
160 1
        return true;
161
    }
162

163
    /**
164
     * Initialise the task.
165
     *
166
     * @return void
167
     */
168 1
    public function init()
169
    {
170 1
        @include_once 'vendor/autoload.php';
171
    }
172

173 1
    public function getFactoryInstance($command, $options = [])
174
    {
175 1
        $vchq = '\\Siad007\\VersionControl\\HG\\Factory';
176 1
        self::$factory = $vchq::getInstance($command, $options);
177 1
        return self::$factory;
178
    }
179
}

Read our documentation on viewing source code .

Loading