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

jomweb / billplz / 22912138050

10 Mar 2026 04:09PM UTC coverage: 73.745% (-23.8%) from 97.537%
22912138050

Pull #59

github

web-flow
Merge f68ad896b into 7e55fdd4e
Pull Request #59: Release Billplz 6.0 with Money objects, bundled Codex internals, and updated CI

263 of 443 new or added lines in 24 files covered. (59.37%)

3 existing lines in 2 files now uncovered.

514 of 697 relevant lines covered (73.74%)

24.87 hits per line

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

78.95
/src/Internal/Codex/Client.php
1
<?php
2

3
namespace Laravie\Codex;
4

5
use InvalidArgumentException;
6

7
abstract class Client implements Contracts\Client
8
{
9
    use Common\HttpClient;
10

11
    /**
12
     * The API endpoint.
13
     *
14
     * @var string
15
     */
16
    protected $apiEndpoint;
17

18
    /**
19
     * Default API version.
20
     *
21
     * @var string
22
     */
23
    protected $defaultVersion = 'v1';
24

25
    /**
26
     * List of supported API versions.
27
     *
28
     * @var array<string, string>
29
     */
30
    protected $supportedVersions = [];
31

32
    /**
33
     * Dump HTTP requests for the client.
34
     */
35
    public function queries(): array
36
    {
NEW
37
        return $this->httpRequestQueries;
×
38
    }
39

40
    /**
41
     * Use custom API Endpoint.
42
     *
43
     *
44
     * @return $this
45
     */
46
    public function useCustomApiEndpoint(string $endpoint)
47
    {
48
        $this->apiEndpoint = $endpoint;
1✔
49

50
        return $this;
1✔
51
    }
52

53
    /**
54
     * Use different API version.
55
     *
56
     *
57
     * @return $this
58
     *
59
     * @throws \InvalidArgumentException
60
     */
61
    public function useVersion(string $version)
62
    {
63
        if (! \array_key_exists($version, $this->supportedVersions)) {
119✔
NEW
64
            throw new InvalidArgumentException("API version [{$version}] is not supported.");
×
65
        }
66

67
        $this->defaultVersion = $version;
119✔
68

69
        return $this;
119✔
70
    }
71

72
    /**
73
     * Get API endpoint URL.
74
     */
75
    public function getApiEndpoint(): ?string
76
    {
77
        return $this->apiEndpoint;
70✔
78
    }
79

80
    /**
81
     * Get API default version.
82
     */
83
    public function getApiVersion(): string
84
    {
NEW
85
        return $this->defaultVersion;
×
86
    }
87

88
    /**
89
     * Get versioned resource (service).
90
     *
91
     *
92
     *
93
     * @throws \InvalidArgumentException
94
     */
95
    public function uses(string $service, ?string $version = null): Contracts\Request
96
    {
97
        if (\is_null($version) || ! \array_key_exists($version, $this->supportedVersions)) {
139✔
98
            $version = $this->defaultVersion;
100✔
99
        }
100

101
        $name = str_replace('.', '\\', $service);
139✔
102

103
        /** @var class-string<\Laravie\Codex\Contracts\Request> $class */
104
        $class = sprintf('%s\%s\%s', $this->getResourceNamespace(), $this->supportedVersions[$version], $name);
139✔
105

106
        if (! class_exists($class)) {
139✔
NEW
107
            throw new InvalidArgumentException("Resource [{$service}] for version [{$version}] is not available.");
×
108
        }
109

110
        return $this->via(new $class($this));
139✔
111
    }
112

113
    /**
114
     * Handle uses using via.
115
     */
116
    public function via(Contracts\Request $request): Contracts\Request
117
    {
118
        $request->setClient($this);
139✔
119

120
        return $request;
139✔
121
    }
122

123
    /**
124
     * Prepare request headers.
125
     *
126
     * @param  array<string, mixed>  $headers
127
     * @return array<string, mixed>
128
     */
129
    protected function prepareRequestHeaders(array $headers = []): array
130
    {
131
        return $headers;
67✔
132
    }
133

134
    /**
135
     * Get resource default namespace.
136
     */
137
    abstract protected function getResourceNamespace(): string;
138
}
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