Completed
Pull Request — master (#586)
by Greg
05:17
created

Config   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 6 1
A useGlobal() 0 5 1
A repository() 0 7 1
A removeRepository() 0 5 1
A disableRepository() 0 6 1
A enableRepository() 0 6 1
A run() 0 6 1
1
<?php
2
namespace Robo\Task\Composer;
3
4
/**
5
 * Composer Config
6
 *
7
 * ``` php
8
 * <?php
9
 * // simple execution
10
 * $this->taskComposerConfig()->set('bin-dir', 'bin/')->run();
11
 * ?>
12
 * ```
13
 */
14
class Config extends Base
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected $action = 'config';
20
21
    /**
22
     * Set a configuration value
23
     * @return $this
24
     */
25
    public function set($key, $value)
26
    {
27
        $this->arg($key);
28
        $this->arg($value);
29
        return $this;
30
    }
31
32
    /**
33
     * Operate on the global repository
34
     * @return $this
35
     */
36
    public function useGlobal()
37
    {
38
        $this->option('global');
39
        return $this;
40
    }
41
42
    /**
43
     * @return $this
44
     */
45
    public function repository($id, $uri, $repoType = 'vcs')
46
    {
47
        $this->arg("repositories.$id");
48
        $this->arg($repoType);
49
        $this->arg($uri);
50
        return $this;
51
    }
52
53
    /**
54
     * @return $this
55
     */
56
    public function removeRepository($id)
57
    {
58
        $this->option('unset', "repositories.$id");
59
        return $this;
60
    }
61
62
    /**
63
     * @return $this
64
     */
65
    public function disableRepository($id)
66
    {
67
        $this->arg("repositories.$id");
68
        $this->arg('false');
69
        return $this;
70
    }
71
72
    /**
73
     * @return $this
74
     */
75
    public function enableRepository($id)
76
    {
77
        $this->arg("repositories.$id");
78
        $this->arg('true');
79
        return $this;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function run()
86
    {
87
        $command = $this->getCommand();
88
        $this->printTaskInfo('Configuring composer.json: {command}', ['command' => $command]);
89
        return $this->executeCommand($command);
90
    }
91
}
92