Completed
Branch module_structure (3116d9)
by Pablo
02:56
created

PrePush::doRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 2
Metric Value
c 4
b 0
f 2
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace PhpGitHooks\Infrastructure\Hook;
4
5
require_once __DIR__.'/../../../../app/AppKernel.php';
6
7
use AppKernel;
8
use PhpGitHooks\Module\Git\Contract\Command\PrePushToolCommand;
9
use PhpGitHooks\Module\Git\Contract\CommandHandler\PrePushToolCommandHandler;
10
use Symfony\Component\Console\Application;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class PrePush extends Application
15
{
16
    /**
17
     * @var AppKernel
18
     */
19
    private $container;
20
    /**
21
     * @var string
22
     */
23
    private $remote;
24
    /**
25
     * @var string
26
     */
27
    private $url;
28
29
    /**
30
     * PrePush constructor.
31
     *
32
     * @param string $remote
33
     * @param string $url
34
     */
35
    public function __construct($remote, $url)
36
    {
37
        $this->container = new AppKernel();
38
        parent::__construct('pre-push');
39
        $this->remote = $remote;
40
        $this->url = $url;
41
    }
42
43
    public function doRun(InputInterface $input, OutputInterface $output)
44
    {
45
        /** @var PrePushToolCommandHandler $command */
46
        $command = $this->container->get('command.bus');
47
        $command->handle(new PrePushToolCommand($this->remote, $this->url));
48
    }
49
}
50