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

lmc-eu / matej-client-php / 7527331519

15 Jan 2024 10:11AM UTC coverage: 100.0%. Remained the same
7527331519

Pull #135

github

web-flow
Merge 117257645 into 9666a6254
Pull Request #135: Update to new coding standard

20 of 21 new or added lines in 5 files covered. (95.24%)

400 existing lines in 23 files now uncovered.

758 of 758 relevant lines covered (100.0%)

18.54 hits per line

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

100.0
/src/Exception/ResponseDecodingException.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Exception;
4

5
use Psr\Http\Message\ResponseInterface;
6

7
/**
8
 * Exception thrown when Matej response cannot be decoded.
9
 */
10
final class ResponseDecodingException extends \RuntimeException implements MatejExceptionInterface
11
{
12
    public static function forJsonError(string $jsonErrorMsg, ResponseInterface $response): self
13
    {
UNCOV
14
        return new self(
4✔
UNCOV
15
            sprintf(
4✔
UNCOV
16
                "Error decoding Matej response: %s\n\nStatus code: %s %s\nBody:\n%s",
4✔
UNCOV
17
                $jsonErrorMsg,
3✔
UNCOV
18
                $response->getStatusCode(),
4✔
UNCOV
19
                $response->getReasonPhrase(),
4✔
UNCOV
20
                $response->getBody()
4✔
UNCOV
21
            )
3✔
UNCOV
22
        );
3✔
23
    }
24

25
    public static function forInvalidData(ResponseInterface $response): self
26
    {
UNCOV
27
        return new self(
4✔
UNCOV
28
            sprintf(
4✔
UNCOV
29
                "Error decoding Matej response: required data missing.\n\nBody:\n%s",
4✔
UNCOV
30
                $response->getBody()
4✔
UNCOV
31
            )
3✔
UNCOV
32
        );
3✔
33
    }
34

35
    public static function forInconsistentNumberOfCommands(int $numberOfCommands, int $commandResponsesCount): self
36
    {
UNCOV
37
        return new self(
8✔
UNCOV
38
            sprintf(
8✔
UNCOV
39
                'Provided numberOfCommands (%d) is inconsistent with actual count of command responses (%d)',
8✔
UNCOV
40
                $numberOfCommands,
6✔
UNCOV
41
                $commandResponsesCount
6✔
UNCOV
42
            )
6✔
UNCOV
43
        );
6✔
44
    }
45

46
    public static function forInconsistentNumbersOfCommandProperties(
47
        int $numberOfCommands,
48
        int $numberOfSuccessfulCommands,
49
        int $numberOfFailedCommands,
50
        int $numberOfSkippedCommands
51
    ): self {
UNCOV
52
        return new self(
4✔
UNCOV
53
            sprintf(
4✔
UNCOV
54
                'Provided numberOfCommands (%d) is inconsistent with provided sum of '
4✔
UNCOV
55
                . 'numberOfSuccessfulCommands (%d) + numberOfFailedCommands (%d)'
3✔
UNCOV
56
                . ' + numberOfSkippedCommands (%d)',
4✔
UNCOV
57
                $numberOfCommands,
3✔
UNCOV
58
                $numberOfSuccessfulCommands,
3✔
UNCOV
59
                $numberOfFailedCommands,
3✔
UNCOV
60
                $numberOfSkippedCommands
3✔
UNCOV
61
            )
3✔
UNCOV
62
        );
3✔
63
    }
64
}
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