• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmc-eu / matej-client-php / 7529439147

15 Jan 2024 01:18PM UTC coverage: 100.0%. Remained the same
7529439147

Pull #145

github

web-flow
Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #145: Bump actions/checkout from 3 to 4

712 of 712 relevant lines covered (100.0%)

35.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Http/ResponseDecoder.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Http;
4

5
use Lmc\Matej\Exception\ResponseDecodingException;
6
use Lmc\Matej\Model\Response;
7
use Psr\Http\Message\ResponseInterface;
8

9
class ResponseDecoder implements ResponseDecoderInterface
10
{
11
    public function decode(ResponseInterface $httpResponse, string $responseClass = Response::class): Response
12
    {
13
        $responseData = json_decode($httpResponse->getBody()->getContents());
42✔
14

15
        if (json_last_error() !== JSON_ERROR_NONE) {
42✔
16
            throw ResponseDecodingException::forJsonError(json_last_error_msg(), $httpResponse);
7✔
17
        }
18

19
        if (!$this->isResponseValid($responseData)) {
35✔
20
            throw ResponseDecodingException::forInvalidData($httpResponse);
7✔
21
        }
22

23
        $responseId = $httpResponse->getHeader(RequestManager::RESPONSE_ID_HEADER)[0] ?? null;
28✔
24

25
        /** @phpstan-ignore-next-line */
26
        return new $responseClass(
28✔
27
            (int) $responseData->commands->number_of_commands,
28✔
28
            (int) $responseData->commands->number_of_successful_commands,
28✔
29
            (int) $responseData->commands->number_of_failed_commands,
28✔
30
            (int) $responseData->commands->number_of_skipped_commands,
28✔
31
            $responseData->commands->responses,
28✔
32
            $responseId
28✔
33
        );
28✔
34
    }
35

36
    private function isResponseValid(\stdClass $responseData): bool
37
    {
38
        return isset(
35✔
39
            $responseData->commands,
35✔
40
            $responseData->commands->number_of_commands,
35✔
41
            $responseData->commands->number_of_successful_commands,
35✔
42
            $responseData->commands->number_of_failed_commands,
35✔
43
            $responseData->commands->number_of_skipped_commands,
35✔
44
            $responseData->commands->responses,
35✔
45
            $responseData->message,
35✔
46
            $responseData->status
35✔
47
        );
35✔
48
    }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc