Completed
Push — master ( b9bd0c...5cd7db )
by Sebastien
08:53
created

Job::isPatternNested()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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