GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FsTask::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * See class comment
4
 *
5
 * PHP Version 5
6
 *
7
 * @category   Netresearch
8
 * @package    Netresearch\Kite
9
 * @subpackage Task
10
 * @author     Christian Opitz <[email protected]>
11
 * @license    http://www.netresearch.de Netresearch Copyright
12
 * @link       http://www.netresearch.de
13
 */
14
15
namespace Netresearch\Kite\Task;
16
17
18
use Netresearch\Kite\Exception;
19
use Netresearch\Kite\Task;
20
21
/**
22
 * Filesystem task - calls methods on {@see \Netresearch\Kite\Service\Filesystem}
23
 * 
24
 * @method Task|void delete($file) {@see \Netresearch\Kite\Service\Filesystem::remove()}
25
 * @method Task|bool isDirEmpty($dir) {@see \Netresearch\Kite\Service\Filesystem::isDirEmpty()}
26
 * @method Task|bool removeDirectory($directory) {@see \Netresearch\Kite\Service\Filesystem::removeDirectory()}
27
 * @method Task|bool removeDirectoryPhp($directory) {@see \Netresearch\Kite\Service\Filesystem::removeDirectoryPhp()}
28
 * @method Task|void ensureDirectoryExists($directory) {@see \Netresearch\Kite\Service\Filesystem::ensureDirectoryExists()}
29
 * @method Task|void copyThenRemove($source, $target) {@see \Netresearch\Kite\Service\Filesystem::copyThenRemove()}
30
 * @method Task|void copy($source, $target) {@see \Netresearch\Kite\Service\Filesystem::copy()}
31
 * @method Task|void rename($source, $target) {@see \Netresearch\Kite\Service\Filesystem::rename()}
32
 * @method Task|string findShortestPath($from, $to, $directories = false) {@see \Netresearch\Kite\Service\Filesystem::findShortestPath()}
33
 * @method Task|string findShortestPathCode($from, $to, $directories = false) {@see \Netresearch\Kite\Service\Filesystem::findShortestPathCode()}
34
 * @method Task|bool isAbsolutePath($path) {@see \Netresearch\Kite\Service\Filesystem::isAbsolutePath()}
35
 * @method Task|int size($path) {@see \Netresearch\Kite\Service\Filesystem::size()}
36
 * @method Task|string normalizePath($path) {@see \Netresearch\Kite\Service\Filesystem::normalizePath()}
37
 *
38
 * @category   Netresearch
39
 * @package    Netresearch\Kite
40
 * @subpackage Task
41
 * @author     Christian Opitz <[email protected]>
42
 * @license    http://www.netresearch.de Netresearch Copyright
43
 * @link       http://www.netresearch.de
44
 */
45
class FsTask extends Task
46
{
47
    protected $started = false;
48
49
    /**
50
     * Configure the options
51
     *
52
     * @return array
53
     */
54 View Code Duplication
    protected function configureVariables()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        return array(
57
            'action' => array(
58
                'type' => 'string',
59
                'required' => true,
60
                'label' => 'Method of \Netresearch\Kite\Service\Filesystem to execute',
61
            ),
62
            'arguments' => array(
63
                'type' => 'array',
64
                'default' => array(),
65
                'label' => 'Arguments for action method',
66
            )
67
        ) + parent::configureVariables();
68
    }
69
70
    /**
71
     * Call the action method or set it for later execution
72
     *
73
     * @param string $name      The method name
74
     * @param array  $arguments The arguments
75
     *
76
     * @return $this|mixed
77
     */
78
    function __call($name, $arguments)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
79
    {
80
        if (!$this->started) {
81
            $this->offsetSet('action', $name);
82
            $this->offsetSet('arguments', $arguments);
83
            return $this;
84
        }
85
86
        foreach ($arguments as &$argument) {
87
            $argument = $this->expand($argument);
88
        }
89
90
        return call_user_func_array(
91
            array($this->console->getFilesystem(), $name),
92
            $arguments
93
        );
94
    }
95
96
    /**
97
     * Call the method or return $this for later method execution
98
     *
99
     * @return $this|mixed
100
     */
101
    public function execute()
102
    {
103
        $this->started = true;
104
105
        if (!$this->offsetExists('action')) {
106
            // Likely called during execution and __call is still pending
107
            return $this;
108
        }
109
110
        return $this->__call($this->get('action'), $this->offsetGet('arguments'));
111
    }
112
}
113
?>
114