GetLicenseMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 2
A __construct() 0 3 1
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