Completed
Push — master ( 7eae42...8f150d )
by Thiago
10:26
created

User   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A execute() 0 17 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace User\Console;
5
6
use Knp\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * User Console
12
 *
13
 * @author Thiago Paes <[email protected]>
14
 */
15
class User extends Command
16
{
17
    /**
18
     * Show helper
19
     *
20
     * @return void
21
     */
22
    public function configure()
23
    {
24
        $this->setName('users:list')->setDescription('List all users');
25
    }
26
27
    /**
28
     * Execute command
29
     *
30
     * @param  InputInterface $input
31
     * @param  OutputInterface $output
32
     * @return string
33
     */
34
    public function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        /* @var $consoleApp \Knp\Console\Application */
37
        $consoleApp = $this->getApplication();
38
39
        /* @var $app \Bootstrap */
40
        $app = $consoleApp->getSilexApplication();
41
42
        $result = $app['user.service']->listAll();
43
44
        /* @var $user \User\Entity\UserInterface */
45
        array_Walk($result, function($user) use($output) {
46
            $output->writeln($user->getName() . ' - ' . $user->getEmail());
47
        });
48
49
        return true;
50
    }
51
}
52