Completed
Push — develop ( 5f7df1...9cb564 )
by Matteo
10s
created

CloneCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A cloneUrl() 0 11 2
1
<?php
2
/**
3
 * GitElephant - An abstraction layer for git written in PHP
4
 * Copyright (C) 2013  Matteo Giachino
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
18
 */
19
20
namespace GitElephant\Command;
21
22
use \GitElephant\Repository;
23
24
/**
25
 * CloneCommand generator
26
 *
27
 * @author Matteo Giachino <[email protected]>
28
 */
29
class CloneCommand extends BaseCommand
30
{
31
    const GIT_CLONE_COMMAND = 'clone';
32
33
    /**
34
     * constructor
35
     *
36
     * @param \GitElephant\Repository $repo The repository object this command 
37
     *                                      will interact with
38
     */
39 3
    public function __construct(Repository $repo = null)
40
    {
41 3
        parent::__construct($repo);
42 3
    }
43
44
    /**
45
     * Command to clone a repository
46
     *
47
     * @param string $url repository url
48
     * @param string $to  where to clone the repo
49
     *
50
     * @throws \RuntimeException
51
     * @return string command
52
     */
53 3
    public function cloneUrl($url, $to = null)
54
    {
55 3
        $this->clearAll();
56 3
        $this->addCommandName(static::GIT_CLONE_COMMAND);
57 3
        $this->addCommandSubject($url);
58 3
        if (null !== $to) {
59 3
            $this->addCommandSubject2($to);
60 3
        }
61
62 3
        return $this->getCommand();
63
    }
64
}
65