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

tylernathanreed / jira-client-php / 13957812811

19 Mar 2025 10:20PM UTC coverage: 72.327% (+0.004%) from 72.323%
13957812811

push

github

tylernathanreed
+ Added getExpandedUri() to PendingOperation

3 of 5 new or added lines in 3 files covered. (60.0%)

4966 of 6866 relevant lines covered (72.33%)

9.24 hits per line

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

50.0
/src/Processor.php
1
<?php
2

3
namespace Jira\Client;
4

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

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

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

31
        if ($status === 404) {
477✔
32
            throw new NotFoundHttpException(sprintf(
×
33
                '[404] Endpoint [%s] not found.',
×
NEW
34
                $operation->getExpandedUri()
×
35
            ), 404);
×
36
        }
37

38
        if ($status === 405) {
477✔
39
            throw new MethodNotAllowedHttpException(sprintf(
×
40
                '[405] Method [%s] against [%s] is not allowed.',
×
41
                strtoupper($operation->method),
×
NEW
42
                $operation->getExpandedUri(),
×
43
            ), 405);
×
44
        }
45

46
        if ($status != $successCode) {
477✔
47
            throw new UnsupportedStatusCodeHttpException(sprintf(
×
48
                '[%s] Unexpected status code (Expected: %s).',
×
49
                $status,
×
50
                $successCode,
×
51
            ), $status);
×
52
        }
53

54
        if ($schema === true) {
477✔
55
            return true;
137✔
56
        }
57

58
        $body = (string) $response->getBody();
340✔
59

60
        $data = json_decode($body, true);
340✔
61

62
        if (! is_array($data)) {
340✔
63
            throw new InvalidBodyHttpException('Unable to decode response body: ' . $body);
×
64
        }
65

66
        if (is_array($schema)) {
340✔
67
            /** @var list<array<string,mixed>> $data */
68
            return $this->deserializer->deserialize($data, $schema[0], array: true);
42✔
69
        } else {
70
            /** @var array<string,mixed> $data */
71
            return $this->deserializer->deserialize($data, $schema);
298✔
72
        }
73
    }
74
}
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