Completed
Push — master ( 81db43...f030be )
by Aleh
12s
created

UpdateCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 5
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A executeAsync() 0 14 1
1
<?php
2
3
namespace Padawan\Command;
4
5
use Padawan\Domain\Project;
6
use Padawan\Domain\ProjectRepository;
7
use Padawan\Domain\Generator\IndexGenerator;
8
use Padawan\Framework\Domain\Project\Persister;
9
use Padawan\Framework\Domain\Project\InMemoryIndex;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Padawan\Framework\Application\Socket\SocketOutput;
13
14
class UpdateCommand extends AsyncCommand
15
{
16
    protected function configure()
17
    {
18
        $this->setName("update")
19
            ->setDescription("Updates index for the project")
20
            ->addArgument(
21
                "path",
22
                InputArgument::REQUIRED,
23
                "Path to the project root. Default: current directory"
24
            );
25
    }
26
    protected function executeAsync(InputInterface $input, SocketOutput $output)
27
    {
28
        $path = $input->getArgument("path");
29
30
        $projectRepository = $this->getContainer()->get(ProjectRepository::class);
31
        $project = $projectRepository->findByPath($path);
32
        $generator = $this->getContainer()->get(IndexGenerator::class);
33
34
        $generator->generateProjectIndex($project, false);
35
        $persister = $this->getContainer()->get(Persister::class);
36
37
        yield $output->disconnect();
38
        yield $persister->save($project);
39
    }
40
}
41