Commit   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getCommand() 0 4 1
A name() 0 5 1
1
<?php
2
3
namespace Robo\Task\Docker;
4
5
/**
6
 * Commits docker container to an image
7
 *
8
 * ```
9
 * $this->taskDockerCommit($containerId)
10
 *      ->name('my/database')
11
 *      ->run();
12
 *
13
 * // alternatively you can take the result from DockerRun task:
14
 *
15
 * $result = $this->taskDockerRun('db')
16
 *      ->exec('./prepare_database.sh')
17
 *      ->run();
18
 *
19
 * $task->dockerCommit($result)
20
 *      ->name('my/database')
21
 *      ->run();
22
 * ```
23
 */
24
class Commit extends Base
25
{
26
    /**
27
     * @var string
28
     */
29
    protected $command = "docker commit";
30
31
    /**
32
     * @var string
33
     */
34
    protected $name;
35
36
    /**
37
     * @var string
38
     */
39
    protected $cid;
40
41
    /**
42
     * @param string|\Robo\Task\Docker\Result $cidOrResult
43
     */
44
    public function __construct($cidOrResult)
45
    {
46
        $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getCommand()
53
    {
54
        return $this->command . ' ' . $this->cid . ' ' . $this->name . ' ' . $this->arguments;
55
    }
56
57
    /**
58
     * @param string $name
59
     *
60
     * @return $this
61
     */
62
    public function name($name)
63
    {
64
        $this->name = $name;
65
        return $this;
66
    }
67
}
68