PingMethod::__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\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