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

tylernathanreed / jira-client-php / 13678007438

05 Mar 2025 02:15PM UTC coverage: 2.081% (+0.01%) from 2.067%
13678007438

push

github

tylernathanreed
Merge branch 'master' of github.com:tylernathanreed/jira-client-php

141 of 6775 relevant lines covered (2.08%)

0.03 hits per line

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

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

3
namespace Jira\Client;
4

5
use RuntimeException;
6
use Psr\Http\Message\ResponseInterface;
7

8
class Processor
9
{
10
    public function __construct(
2✔
11
        protected Deserializer $deserializer
12
    ) {
13
    }
2✔
14

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

28
        if ($status === 404) {
2✔
29
            throw new RuntimeException(sprintf(
×
30
                '[404] Endpoint [%s] not found.',
×
31
                $operation->uri
×
32
            ), 404);
×
33
        }
34

35
        if ($status === 405) {
2✔
36
            throw new RuntimeException(sprintf(
×
37
                '[405] Method [%s] against [%s] is not allowed.',
×
38
                strtoupper($operation->method),
×
39
                $operation->uri,
×
40
            ), 405);
×
41
        }
42

43
        if ($status != $successCode) {
2✔
44
            throw new RuntimeException(sprintf(
×
45
                '[%s] Unexpected status code (Expected: %s).',
×
46
                $status,
×
47
                $successCode,
×
48
            ), $status);
×
49
        }
50

51
        if ($schema === true) {
2✔
52
            return true;
1✔
53
        }
54

55
        $body = (string) $response->getBody();
1✔
56

57
        $data = json_decode($body, true);
1✔
58

59
        if (! is_array($data)) {
1✔
60
            throw new RuntimeException('Unable to decode response body: ' . $body);
×
61
        }
62

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