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

tylernathanreed / jira-client-php / 14523164870

17 Apr 2025 07:18PM UTC coverage: 81.598% (-0.05%) from 81.645%
14523164870

push

github

tylernathanreed
~ More explicit exceptions

0 of 17 new or added lines in 2 files covered. (0.0%)

5738 of 7032 relevant lines covered (81.6%)

10.34 hits per line

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

57.69
/src/Http/Processor.php
1
<?php
2

3
namespace Jira\Client\Http;
4

5
use Jira\Client\Http\Exceptions\InvalidBodyHttpException;
6
use Jira\Client\Http\Exceptions\MethodNotAllowedHttpException;
7
use Jira\Client\Http\Exceptions\NotFoundHttpException;
8
use Jira\Client\Http\Exceptions\UnsupportedStatusCodeHttpException;
9

10
class Processor
11
{
12
    public function __construct(
512✔
13
        protected Deserializer $deserializer
14
    ) {
15
    }
512✔
16

17
    /**
18
     * @param array{0:class-string<Dto>}|class-string<Dto>|true $schema
19
     *
20
     * @return ($schema is true ? true : ($schema is array ? list<Dto> : Dto))
21
     */
22
    public function process(
512✔
23
        PendingOperation $operation,
24
        Response $response,
25
        int $successCode,
26
        array|string|bool $schema
27
    ): array|Dto|bool {
28
        $status = $response->status;
512✔
29

30
        if ($status === 404) {
512✔
NEW
31
            throw new NotFoundHttpException($response, $operation->getExpandedUri());
×
32
        }
33

34
        if ($status === 405) {
512✔
NEW
35
            throw new MethodNotAllowedHttpException($response, sprintf(
×
NEW
36
                '%s@%s',
×
37
                $operation->getExpandedUri(),
×
NEW
38
                strtoupper($operation->method),
×
NEW
39
            ));
×
40
        }
41

42
        if ($status != $successCode) {
512✔
NEW
43
            throw new UnsupportedStatusCodeHttpException($response, sprintf(
×
NEW
44
                'Unsupported Status Code (Expected: %s).',
×
45
                $successCode,
×
NEW
46
            ));
×
47
        }
48

49
        if ($schema === true) {
512✔
50
            return true;
140✔
51
        }
52

53
        $body = (string) $response->body;
372✔
54

55
        $data = json_decode($body, true);
372✔
56

57
        if (! is_array($data)) {
372✔
NEW
58
            throw new InvalidBodyHttpException($response, 'Unable to decode response body: ' . $body);
×
59
        }
60

61
        if (is_array($schema)) {
372✔
62
            /** @var list<array<string,mixed>> $data */
63
            return $this->deserializer->deserialize($data, $schema[0], array: true);
46✔
64
        } else {
65
            /** @var array<string,mixed> $data */
66
            return $this->deserializer->deserialize($data, $schema);
326✔
67
        }
68
    }
69
}
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