Command   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 16
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A generate() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ParcelValue\ApiClient\Domain\AuthenticationHash;
6
7
use WebServCo\Framework\Cli\Ansi;
8
use WebServCo\Framework\Cli\Response;
9
use WebServCo\Framework\Cli\Sgr;
10
use WebServCo\Framework\Interfaces\ResponseInterface;
11
12
final class Command extends \ParcelValue\ApiClient\AbstractController
13
{
14
    use \ParcelValue\ApiClient\Traits\ControllerApiTrait;
15
16
    protected \WebServCo\Framework\Interfaces\OutputLoggerInterface $outputLogger;
17
18
    public function __construct()
19
    {
20
        parent::__construct();
21
22
        $this->outputLogger = new \WebServCo\Framework\Log\CliOutputLogger();
23
    }
24
25
    public function generate(string $username, string $password): ResponseInterface
26
    {
27
        $this->init();
28
29
        $this->outputLogger->output(Ansi::clear(), true);
30
        $this->outputLogger->output(Ansi::sgr(__METHOD__, [Sgr::BOLD]), true);
31
        $this->outputLogger->output('');
32
33
        $hash = \hash('sha256', \sprintf('%s:%s', \trim($username), \md5(\trim($password))));
34
35
        $this->outputLogger->output(Ansi::sgr('Success!', [Sgr::GREEN]), false);
36
        $this->outputLogger->output(' Your hash is:', true);
37
        $this->outputLogger->output('');
38
        $this->outputLogger->output($hash, true);
39
        $this->outputLogger->output('');
40
        return new Response();
41
    }
42
}
43