ExportTask::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Conveyor package.
5
 *
6
 * (c) Jeroen Fiege <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webcreate\Conveyor\Task;
13
14
use Webcreate\Conveyor\IO\IOInterface;
15
use Webcreate\Conveyor\Repository\Repository;
16
use Webcreate\Conveyor\Repository\Version;
17
use Webcreate\Conveyor\Task\Result\ExecuteResult;
18
19
class ExportTask extends Task
20
{
21
    protected $io;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $io. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
22
    protected $repository;
23
24 1
    public function __construct($dest, Repository $repository, IOInterface $io = null)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $io. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
25
    {
26 1
        $this->repository = $repository;
27 1
        $this->io = $io;
28 1
        $this->dest = $dest;
0 ignored issues
show
Bug introduced by
The property dest does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29 1
    }
30
31
    /**
32
     * @todo better progress (percentage) updating
33
     *
34
     * @param $target
35
     * @param  Version       $version
36
     * @param  array         $options
37
     * @return ExecuteResult
38
     */
39 1
    public function execute($target, Version $version, array $options = array())
40
    {
41 1
        $this->output(sprintf('Exporting: <comment>0%%</comment>'));
42
43 1
        $this->repository->export($version, $this->dest);
44
45 1
        $this->output(sprintf('Exporting: <comment>100%%</comment>'));
46
47 1
        return new ExecuteResult(
48 1
            array('*')
49
        );
50
    }
51
}
52