• 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/Model/Response.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Model;
4

5
use Lmc\Matej\Exception\ResponseDecodingException;
6

7
class Response
8
{
9
    /** @var CommandResponse[] */
10
    private $commandResponses = [];
11
    /** @var int */
12
    private $numberOfCommands;
13
    /** @var int */
14
    private $numberOfSuccessfulCommands;
15
    /** @var int */
16
    private $numberOfFailedCommands;
17
    /** @var int */
18
    private $numberOfSkippedCommands;
19
    /** @var string|null */
20
    private $responseId;
21

22
    public function __construct(
23
        int $numberOfCommands,
24
        int $numberOfSuccessfulCommands,
25
        int $numberOfFailedCommands,
26
        int $numberOfSkippedCommands,
27
        array $commandResponses = [],
28
        string $responseId = null
29
    ) {
30
        $this->numberOfCommands = $numberOfCommands;
133✔
31
        $this->numberOfSuccessfulCommands = $numberOfSuccessfulCommands;
133✔
32
        $this->numberOfFailedCommands = $numberOfFailedCommands;
133✔
33
        $this->numberOfSkippedCommands = $numberOfSkippedCommands;
133✔
34
        $this->responseId = $responseId;
133✔
35

36
        $this->commandResponses = $this->decodeRawCommandResponses($commandResponses);
133✔
37

38
        if ($this->numberOfCommands !== count($commandResponses)) {
133✔
39
            throw ResponseDecodingException::forInconsistentNumberOfCommands(
14✔
40
                $this->numberOfCommands,
14✔
41
                count($commandResponses)
14✔
42
            );
14✔
43
        }
44

45
        $commandSum = $this->numberOfSuccessfulCommands + $this->numberOfFailedCommands
119✔
46
            + $this->numberOfSkippedCommands;
119✔
47

48
        if ($this->numberOfCommands !== $commandSum) {
119✔
49
            throw ResponseDecodingException::forInconsistentNumbersOfCommandProperties(
7✔
50
                $this->numberOfCommands,
7✔
51
                $this->numberOfSuccessfulCommands,
7✔
52
                $this->numberOfFailedCommands,
7✔
53
                $this->numberOfSkippedCommands
7✔
54
            );
7✔
55
        }
56
        $this->responseId = $responseId;
112✔
57
    }
58

59
    protected function decodeRawCommandResponses(array $commandResponses): array
60
    {
61
        $decodedResponses = [];
112✔
62
        foreach ($commandResponses as $rawCommandResponse) {
112✔
63
            $decodedResponses[] = CommandResponse::createFromRawCommandResponseObject($rawCommandResponse);
98✔
64
        }
65

66
        return $decodedResponses;
112✔
67
    }
68

69
    public function getNumberOfCommands(): int
70
    {
71
        return $this->numberOfCommands;
70✔
72
    }
73

74
    public function getNumberOfSuccessfulCommands(): int
75
    {
76
        return $this->numberOfSuccessfulCommands;
70✔
77
    }
78

79
    public function getNumberOfFailedCommands(): int
80
    {
81
        return $this->numberOfFailedCommands;
77✔
82
    }
83

84
    public function getNumberOfSkippedCommands(): int
85
    {
86
        return $this->numberOfSkippedCommands;
70✔
87
    }
88

89
    /**
90
     * Return individual command response by its index (0 indexed)
91
     */
92
    public function getCommandResponse(int $index): CommandResponse
93
    {
94
        return $this->commandResponses[$index];
84✔
95
    }
96

97
    /**
98
     * Each Command which was part of request batch has here corresponding CommandResponse - on the same index on which
99
     * the Command was added to the request batch.
100
     *
101
     * @return CommandResponse[]
102
     */
103
    public function getCommandResponses(): array
104
    {
105
        return $this->commandResponses;
70✔
106
    }
107

108
    public function getResponseId(): ?string
109
    {
110
        return $this->responseId;
70✔
111
    }
112

113
    public function isSuccessful(): bool
114
    {
115
        return $this->getNumberOfFailedCommands() === 0;
63✔
116
    }
117
}
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