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

3
namespace Lmc\Matej\Model;
4

5
use Lmc\Matej\Exception\ResponseDecodingException;
6

7
/**
8
 * Response to one single command which was part of request batch.
9
 */
10
class CommandResponse
11
{
12
    public const STATUS_OK = 'OK';
13
    /** @deprecated */
14
    public const STATUS_ERROR = 'ERROR';
15
    public const STATUS_SKIPPED = 'SKIPPED';
16
    public const STATUS_INVALID = 'INVALID';
17

18
    /** @var string */
19
    private $status;
20
    /** @var string */
21
    private $message;
22
    /** @var array */
23
    protected $data = [];
24

25
    private function __construct()
26
    {
UNCOV
27
    }
60✔
28

29
    /** @return static */
30
    public static function createFromRawCommandResponseObject(\stdClass $rawCommandResponseObject): self
31
    {
UNCOV
32
        if (!isset($rawCommandResponseObject->status)) {
64✔
UNCOV
33
            throw new ResponseDecodingException('Status field is missing in command response object');
4✔
34
        }
35

UNCOV
36
        $commandResponse = new static();
60✔
UNCOV
37
        $commandResponse->status = $rawCommandResponseObject->status;
60✔
UNCOV
38
        $commandResponse->message = $rawCommandResponseObject->message ?? '';
60✔
UNCOV
39
        $commandResponse->data = $rawCommandResponseObject->data ?? [];
60✔
40

UNCOV
41
        return $commandResponse;
60✔
42
    }
43

44
    public function getStatus(): string
45
    {
UNCOV
46
        return $this->status;
52✔
47
    }
48

49
    public function getMessage(): string
50
    {
UNCOV
51
        return $this->message;
32✔
52
    }
53

54
    public function getData(): array
55
    {
UNCOV
56
        return $this->data;
32✔
57
    }
58

59
    /**
60
     * Use this method to check whether this command response did not fail. Note both OK and SKIPPED statuses
61
     * are in fact marked as successful to provide this "command did not fail" detection.
62
     * This also means `Response::getNumberOfSuccessfulCommands()` don't necessarily return the same number of
63
     * command responses that return true on `CommandResponse::isSuccessful()` (as skipped command responses are
64
     * reported separately in `Response::getNumberOfSkippedCommands()`).
65
     */
66
    public function isSuccessful(): bool
67
    {
UNCOV
68
        return $this->getStatus() === static::STATUS_OK || $this->getStatus() === static::STATUS_SKIPPED;
24✔
69
    }
70
}
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

© 2026 Coveralls, Inc