Failed Conditions
Push — issue#702 ( 91bd46...0b5bf0 )
by Guilherme
19:37 queued 12:15
created

BlockUserCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A getUsers() 0 12 2
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Command;
12
13
use LoginCidadao\CoreBundle\Model\PersonInterface;
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
19
/**
20
 * Class BlockUserCommand
21
 * @package LoginCidadao\CoreBundle\Command
22
 * @codeCoverageIgnore
23
 */
24
class BlockUserCommand extends AbstractPersonBlockCommand
25
{
26
27
    protected function configure()
28
    {
29
        parent::configure();
30
        $this
31
            ->setName('lc:block-user')
32
            ->addArgument('user', InputArgument::REQUIRED, "User's Email, CPF, username or ID")
33
            ->setDescription("Block the user found");
34
    }
35
36
    protected function getUsers(SymfonyStyle $io, InputInterface $input, OutputInterface $output)
37
    {
38
        $io->section("Searching users...");
39
40
        $userManager = $this->getUserManager();
41
        $query = $input->getArgument('user');
42
        $user = $userManager->findUserByUsernameOrEmail($query);
43
        if (!$user instanceof PersonInterface) {
44
            $user = $userManager->findUserBy(['id' => $query]);
45
        }
46
47
        return [$user];
48
    }
49
}
50