GetLicenseMethod::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Usox\HyperSonic\FeatureSet\V1161\Method;
6
7
use Usox\HyperSonic\FeatureSet\V1161\Contract\LicenseDataProviderInterface;
8
use Usox\HyperSonic\FeatureSet\V1161\Responder\ResponderFactoryInterface;
9
use Usox\HyperSonic\Response\ResponderInterface;
10
11
/**
12
 * Retrieves and transforms data related to the license state of the server
13
 *
14
 * This class covers the `getLicense.view` method
15
 */
16
final class GetLicenseMethod implements V1161MethodInterface
17
{
18 2
    public function __construct(
19
        private readonly ResponderFactoryInterface $responderFactory,
20
    ) {
21 2
    }
22
23
    /**
24
     * @param array<string, scalar> $queryParams
25
     * @param array<string, scalar> $args
26
     */
27 1
    public function __invoke(
28
        LicenseDataProviderInterface $licenseDataProvider,
29
        array $queryParams,
30
        array $args
31
    ): ResponderInterface {
32 1
        return $this->responderFactory->createLicenseResponder([
33 1
            'valid' => $licenseDataProvider->isValid() ? 'true' : 'false',
34 1
            'email' => $licenseDataProvider->getEmailAddress(),
35 1
            'licenseExpires' => $licenseDataProvider->getExpiryDate()->format(DATE_ATOM),
36 1
        ]);
37
    }
38
}
39