Passed
Pull Request — master (#56)
by Robbie
04:09 queued 01:16
created

UnlockCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace SilverLeague\Console\Command\Member;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Unlock a user
11
 *
12
 * @package silverstripe-console
13
 * @author  Robbie Averill <[email protected]>
14
 */
15
class UnlockCommand extends AbstractMemberCommand
16
{
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('member:unlock')
21
            ->setDescription('Unlock a member account')
22
            ->addArgument('email', InputArgument::OPTIONAL, 'Email address');
23
    }
24
25
    protected function execute(InputInterface $input, OutputInterface $output)
26
    {
27
        $member = $this->getMember($input, $output);
28
        if (!$member) {
29
            return;
30
        }
31
32
        $member->LockedOutUntil = null;
33
        $member->FailedLoginCount = 0;
34
        $member->write();
35
36
        $output->writeln('Member <info>' . $member->Email . '</info> unlocked.');
37
    }
38
}
39
40