Completed
Push — master ( d012cb...0f7aa6 )
by Fèvre
05:35
created

DeployerShell   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A main() 0 15 3
A getOptionParser() 0 11 1
1
<?php
2
namespace App\Shell;
3
4
use Cake\Console\ConsoleOptionParser;
5
use Cake\Console\Shell;
6
use Cake\Utility\Inflector;
7
8
class DeployerShell extends Shell
9
{
10
    public $tasks = ['ClearCache'];
11
12
    /**
13
     * Start the shell and interactive console.
14
     *
15
     * @return void
16
     */
17
    public function main()
18
    {
19
        $this->out('The following commands can be used when deploying the application.', 2);
20
        $this->out('<info>Available commands:</info>', 2);
21
        $names = [];
22
        foreach ($this->tasks as $task => $value) {
23
            $names[] = Inflector::underscore($task);
24
        }
25
        sort($names);
26
        foreach ($names as $name) {
27
            $this->out('- <error>' . $name . '</error>');
28
        }
29
        $this->out('');
30
        $this->out('By using <info>`cake deployer [name]`</info> you can invoke a specific bake task.');
31
    }
32
33
    /**
34
     * Display help for this console.
35
     *
36
     * @return ConsoleOptionParser
37
     */
38
    public function getOptionParser()
39
    {
40
        $parser = new ConsoleOptionParser('deployer', false);
41
        $parser->description(
42
            'This shell is used when deploying the application.'
43
        )->addSubcommand('clear_cache', [
44
            'help' => 'Clear the cache files.',
45
            'parser' => $this->ClearCache->getOptionParser()
0 ignored issues
show
Documentation introduced by
The property ClearCache does not exist on object<App\Shell\DeployerShell>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
46
        ]);
47
        return $parser;
48
    }
49
}
50