PingMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 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\Exception\ErrorCodeEnum;
8
use Usox\HyperSonic\Exception\MethodCallFailedException;
9
use Usox\HyperSonic\Exception\SubSonicApiException;
10
use Usox\HyperSonic\FeatureSet\V1161\Contract\PingDataProviderInterface;
11
use Usox\HyperSonic\FeatureSet\V1161\Responder\ResponderFactoryInterface;
12
use Usox\HyperSonic\Response\ResponderInterface;
13
14
/**
15
 * Retrieves and transforms data related to the servers state
16
 *
17
 * This class covers the `ping.view` method
18
 */
19
final class PingMethod implements V1161MethodInterface
20
{
21 3
    public function __construct(
22
        private readonly ResponderFactoryInterface $responderFactory,
23
    ) {
24 3
    }
25
26
    /**
27
     * @param array<string, scalar> $queryParams
28
     * @param array<string, scalar> $args
29
     *
30
     * @throws SubSonicApiException
31
     */
32 2
    public function __invoke(
33
        PingDataProviderInterface $dataProvider,
34
        array $queryParams,
35
        array $args
36
    ): ResponderInterface {
37 2
        if (!$dataProvider->isOk()) {
38 1
            throw new MethodCallFailedException(ErrorCodeEnum::GENERIC_ERROR);
39
        }
40
41 1
        return $this->responderFactory->createPingResponder();
42
    }
43
}
44