Command::current()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ParcelValue\ApiClient\Domain\Clients;
6
7
use WebServCo\Framework\Cli\Ansi;
8
use WebServCo\Framework\Cli\Response;
9
use WebServCo\Framework\Cli\Sgr;
10
use WebServCo\Framework\Environment\Config;
11
use WebServCo\Framework\Http\Method;
12
use WebServCo\Framework\Interfaces\ResponseInterface;
13
14
final class Command extends \ParcelValue\ApiClient\AbstractController
15
{
16
    use \ParcelValue\ApiClient\Traits\ControllerApiTrait;
17
18
    protected string $jwt;
19
20
    protected \WebServCo\Framework\Interfaces\OutputLoggerInterface $outputLogger;
21
22
    public function __construct()
23
    {
24
        parent::__construct();
25
26
        $this->jwt = \ParcelValue\Api\JWT\Helper::generate(
27
            Config::string('APP_API_CLIENT_ID'),
28
            Config::string('APP_API_CLIENT_KEY'),
29
            Config::string('APP_API_SERVER_KEY'),
30
        );
31
32
        $this->outputLogger = new \WebServCo\Framework\Log\CliOutputLogger();
33
    }
34
35
    public function current(): ResponseInterface
36
    {
37
        $this->init();
38
39
        $this->outputLogger->output(Ansi::clear(), true);
40
        $this->outputLogger->output(Ansi::sgr(__METHOD__, [Sgr::BOLD]), true);
41
42
        $url = \sprintf('%s%s/clients/current', Config::string('APP_API_URL'), Config::string('APP_API_VERSION'));
43
44
        $this->handleApiCall($this->jwt, $url, Method::GET, '');
45
46
        return new Response();
47
    }
48
}
49