ConsoleUserProvider::setCurrentCommand()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 2
nop 1
dl 0
loc 3
c 1
b 0
f 0
cc 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\AuditorBundle\User;
6
7
use DH\Auditor\User\User;
8
use DH\Auditor\User\UserInterface;
9
use DH\Auditor\User\UserProviderInterface;
10
use Symfony\Component\Console\Command\Command;
11
12
class ConsoleUserProvider implements UserProviderInterface
13
{
14
    private ?string $currentCommand = null;
15
16
    public function __invoke(): ?UserInterface
17
    {
18
        if (null === $this->currentCommand) {
19
            return null;
20
        }
21
22
        return new User(
23
            'command',
24
            $this->currentCommand ?? ''
25
        );
26
    }
27
28
    public function setCurrentCommand(?Command $command): void
29
    {
30
        $this->currentCommand = null === $command ? null : $command->getName();
31
    }
32
}
33