DeployerShell   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A main() 0 19 3
A getOptionParser() 0 12 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
23
        foreach ($this->tasks as $task => $value) {
24
            $names[] = Inflector::underscore($task);
25
        }
26
27
        sort($names);
28
29
        foreach ($names as $name) {
30
            $this->out('- <error>' . $name . '</error>');
31
        }
32
33
        $this->out('');
34
        $this->out('By using <info>`cake deployer [name]`</info> you can invoke a specific bake task.');
35
    }
36
37
    /**
38
     * Display help for this console.
39
     *
40
     * @return ConsoleOptionParser
41
     */
42
    public function getOptionParser()
43
    {
44
        $parser = new ConsoleOptionParser('deployer', false);
45
        $parser->description(
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Console\ConsoleOptionParser::description() has been deprecated with message: 3.4.0 Use setDescription()/getDescription() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
46
            'This shell is used when deploying the application.'
47
        )->addSubcommand('clear_cache', [
48
            'help' => 'Clear the cache files.',
49
            '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...
50
        ]);
51
52
        return $parser;
53
    }
54
}
55