Completed
Push — master ( e9ab60...4fa3cf )
by Sebastien
15:37 queued 05:47
created

Job::getAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Cerbere\Model;
4
5
use Cerbere\Action\ActionInterface;
6
use Cerbere\Versioning\VersioningInterface;
7
use Symfony\Component\EventDispatcher\EventDispatcher;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9
10
/**
11
 * Class Job
12
 *
13
 * @package Cerbere\Model
14
 */
15
class Job
16
{
17
    /**
18
     * @var EventDispatcherInterface
19
     */
20
    protected $dispatcher;
21
22
    /**
23
     * @var VersioningInterface
24
     */
25
    protected $versioning = null;
26
27
    /**
28
     * @var ActionInterface
29
     */
30
    protected $action;
31
32
    /**
33
     * @var string
34
     */
35
    protected $source_url;
36
37
    /**
38
     * @var array
39
     */
40
    protected $source_options;
41
42
    /**
43
     * @var array
44
     */
45
    protected $patterns = array();
46
47
    /**
48
     * @var boolean
49
     */
50
    protected $pattern_nested = false;
51
52
    /**
53
     * @var string
54
     */
55
    protected $workingDirectory = '';
56
57
    /**
58
     */
59
    public function __construct()
60
    {
61
    }
62
63
    /**
64
     * @return Job
65
     */
66
    public function checkoutRepository()
67
    {
68
        $this->getVersioning()->prepare($this->source_url);
69
        $workingDirectory = $this->getVersioning()->getWorkingDirectory();
70
        $this->getVersioning()->process($this->source_url, $workingDirectory, $this->source_options);
71
72
        return $workingDirectory;
73
    }
74
75
    /**
76
     * @return VersioningInterface
77
     */
78
    public function getVersioning()
79
    {
80
        return $this->versioning;
81
    }
82
83
    /**
84
     * @param VersioningInterface $versioning
85
     *
86
     * @return Job
87
     */
88
    public function setVersioning(VersioningInterface $versioning)
89
    {
90
        $this->versioning = $versioning;
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return ActionInterface
97
     */
98
    public function getAction()
99
    {
100
        return $this->action;
101
    }
102
103
    /**
104
     * @param ActionInterface $action
105
     */
106
    public function setAction($action)
107
    {
108
        $this->action = $action;
109
    }
110
111
    /**
112
     * Gets the dispatcher used by this library to dispatch events.
113
     *
114
     * @return EventDispatcherInterface
115
     */
116
    public function getDispatcher()
117
    {
118
        if (!isset($this->dispatcher)) {
119
            $this->dispatcher = new EventDispatcher();
120
        }
121
122
        return $this->dispatcher;
123
    }
124
125
    /**
126
     * Sets the dispatcher used by this library to dispatch events.
127
     *
128
     * @param EventDispatcherInterface $dispatcher
129
     *   The Symfony event dispatcher object.
130
     *
131
     * @return $this
132
     */
133
    public function setDispatcher(EventDispatcherInterface $dispatcher)
134
    {
135
        $this->dispatcher = $dispatcher;
136
137
        return $this;
138
    }
139
140
    /**
141
     * @return array
142
     */
143
    public function getPatterns()
144
    {
145
        return $this->patterns;
146
    }
147
148
    /**
149
     * @return boolean
150
     */
151
    public function isPatternNested()
152
    {
153
        return $this->pattern_nested;
154
    }
155
156
    /**
157
     * @param array   $patterns
158
     * @param boolean $nested
159
     *
160
     * @return Job
161
     */
162
    public function setPatterns($patterns, $nested = false)
163
    {
164
        $this->patterns       = $patterns;
165
        $this->pattern_nested = $nested;
166
167
        return $this;
168
    }
169
170
    /**
171
     * @param string $url
172
     * @param array  $options
173
     */
174
    public function setSource($url, $options = array())
175
    {
176
        $this->source_url     = $url;
177
        $this->source_options = $options;
178
    }
179
}
180