VcsSubscriber::onVcsPreExport()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 16
loc 16
ccs 0
cts 8
cp 0
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 6
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\Subscriber;
13
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
use Webcreate\Conveyor\IO\IOInterface;
16
use Webcreate\Vcs\Common\Event\Data\CheckoutEventData;
17
use Webcreate\Vcs\Common\Event\Data\ExportEventData;
18
use Webcreate\Vcs\Common\Event\VcsEvent;
19
use Webcreate\Vcs\Common\VcsEvents;
20
21
class VcsSubscriber implements EventSubscriberInterface
22
{
23
    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...
24
25 1
    public function __construct(IOInterface $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...
26
    {
27 1
        $this->io = $io;
28 1
    }
29
30 1
    public static function getSubscribedEvents()
31
    {
32
        return array(
33 1
            VcsEvents::PRE_CHECKOUT => array('onVcsPreCheckout'),
34 1
            VcsEvents::PRE_EXPORT => array('onVcsPreExport'),
35
        );
36
    }
37
38 View Code Duplication
    public function onVcsPreCheckout(VcsEvent $event)
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...
39
    {
40
        if (false === $this->io->isVerbose()) return;
0 ignored issues
show
Coding Style introduced by
Please always use braces to surround the code block of IF statements.
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
41
42
        /** @var CheckoutEventData $data */
43
        $data = $event->getData();
44
45
        $this->io->write(
46
            sprintf(
47
                'Checking out <comment>%s</comment> to <comment>%s</comment>...'
48
                ,
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
49
                $data->getHead()->getName(),
50
                $data->getDestination()
51
            )
52
        );
53
    }
54
55 View Code Duplication
    public function onVcsPreExport(VcsEvent $event)
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...
56
    {
57
        if (false === $this->io->isVerbose()) return;
0 ignored issues
show
Coding Style introduced by
Please always use braces to surround the code block of IF statements.
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
58
59
        /** @var ExportEventData $data */
60
        $data = $event->getData();
61
62
        $this->io->write(
63
            sprintf(
64
                'Exporting <comment>%s</comment> to <comment>%s</comment>...'
65
                ,
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
66
                $data->getHead()->getName(),
67
                $data->getDestination()
68
            )
69
        );
70
    }
71
}
72