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

Rebilly / rebilly-php / #2508

28 Aug 2023 06:28AM UTC coverage: 82.776% (-0.04%) from 82.813%
#2508

Pull #605

php-coveralls

web-flow
Merge 621eccea7 into 3733c9274
Pull Request #605: Remove deprecated methods

3518 of 4250 relevant lines covered (82.78%)

12.88 hits per line

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

93.86
/src/Entities/Schema.php
1
<?php
2
/**
3
 * This source file is proprietary and part of Rebilly.
4
 *
5
 * (c) Rebilly SRL
6
 *     Rebilly Ltd.
7
 *     Rebilly Inc.
8
 *
9
 * @see https://www.rebilly.com
10
 */
11

12
namespace Rebilly\Entities;
13

14
use ArrayAccess;
15
use ArrayIterator;
16
use InvalidArgumentException;
17
use IteratorAggregate;
18
use Rebilly\Entities\Coupons\Coupon;
19
use Rebilly\Entities\Coupons\Redemption;
20
use Rebilly\Entities\KycDocuments\KycDocument;
21
use Rebilly\Entities\ReadyToPay\ReadyToPay;
22
use Rebilly\Entities\RulesEngine\EventRules;
23
use Rebilly\Rest\Collection;
24

25
/**
26
 * Class Schema.
27
 */
28
final class Schema implements IteratorAggregate, ArrayAccess
29
{
30
    /** @var callable[]|array */
31
    private $builders = [];
32

33
    public function __construct()
34
    {
35
        $this->builders = [
114✔
36
            'bank-accounts' => function (array $content) {
114✔
37
                return new Collection(new BankAccount(), $content);
1✔
38
            },
114✔
39
            'bank-accounts/{bankAccountId}' => function (array $content) {
114✔
40
                return new BankAccount($content);
3✔
41
            },
114✔
42
            'blocklists' => function (array $content) {
114✔
43
                return new Collection(new Blocklist(), $content);
1✔
44
            },
114✔
45
            'blocklists/{blocklistId}' => function (array $content) {
114✔
46
                return new Blocklist($content);
1✔
47
            },
114✔
48
            'websites' => function (array $content) {
114✔
49
                return new Collection(new Website(), $content);
1✔
50
            },
114✔
51
            'websites/{websiteId}' => function (array $content) {
114✔
52
                return new Website($content);
1✔
53
            },
114✔
54
            'files' => function (array $content) {
114✔
55
                return new Collection(new File(), $content);
1✔
56
            },
114✔
57
            'files/{fileId}' => function (array $content) {
114✔
58
                return new File($content);
1✔
59
            },
114✔
60
            'attachments' => function (array $content) {
114✔
61
                return new Collection(new Attachment(), $content);
1✔
62
            },
114✔
63
            'attachments/{attachmentId}' => function (array $content) {
114✔
64
                return new Attachment($content);
1✔
65
            },
114✔
66
            'shipping-rates' => function (array $content) {
114✔
67
                return new Collection(new ShippingRate(), $content);
1✔
68
            },
114✔
69
            'shipping-rates/{shippingRateId}' => function (array $content) {
114✔
70
                return new ShippingRate($content);
1✔
71
            },
114✔
72
            'products' => function (array $content) {
114✔
73
                return new Collection(new Product(), $content);
1✔
74
            },
114✔
75
            'products/{productId}' => function (array $content) {
114✔
76
                return new Product($content);
1✔
77
            },
114✔
78
            'customers' => function (array $content) {
114✔
79
                return new Collection(new Customer(), $content);
4✔
80
            },
114✔
81
            'customers/{customerId}' => function (array $content) {
114✔
82
                return new Customer($content);
5✔
83
            },
114✔
84
            'customers/{customerId}/lead-source' => function (array $content) {
114✔
85
                return new LeadSource($content);
1✔
86
            },
114✔
87
            'lead-sources' => function (array $content) {
114✔
88
                return new Collection(new LeadSource(), $content);
×
89
            },
114✔
90
            'lead-sources/{leadSourceId}' => function (array $content) {
114✔
91
                return new LeadSource($content);
×
92
            },
114✔
93
            'invoices' => function (array $content) {
114✔
94
                return new Collection(new Invoice(), $content);
1✔
95
            },
114✔
96
            'invoices/{invoiceId}' => function (array $content) {
114✔
97
                return new Invoice($content);
3✔
98
            },
114✔
99
            'invoices/{invoiceId}/items' => function (array $content) {
114✔
100
                return new Collection(new InvoiceItem(), $content);
1✔
101
            },
114✔
102
            'invoices/{invoiceId}/items/{invoiceItemId}' => function (array $content) {
114✔
103
                return new InvoiceItem($content);
1✔
104
            },
114✔
105
            'invoices/{invoiceId}/credit-memo-allocations' => function (array $content) {
114✔
106
                return new Collection(new CreditMemoAllocation(), $content);
2✔
107
            },
114✔
108
            'invoices/{invoiceId}/credit-memo-allocations/{creditMemoId}' => function (array $content) {
114✔
109
                return new CreditMemoAllocation($content);
2✔
110
            },
114✔
111
            'invoices/{invoiceId}/lead-source' => function (array $content) {
114✔
112
                return new LeadSource($content);
×
113
            },
114✔
114
            'plans' => function (array $content) {
114✔
115
                return new Collection(new Plan(), $content);
1✔
116
            },
114✔
117
            'plans/{planId}' => function (array $content) {
114✔
118
                return new Plan($content);
1✔
119
            },
114✔
120
            'subscriptions' => function (array $content) {
114✔
121
                return new Collection(new Subscription(), $content);
1✔
122
            },
114✔
123
            'subscriptions/{subscriptionId}' => function (array $content) {
114✔
124
                return new Subscription($content);
2✔
125
            },
114✔
126
            'subscriptions/{subscriptionId}/change-items' => function (array $content) {
114✔
127
                return new Subscription($content);
×
128
            },
114✔
129
            'subscriptions/{subscriptionId}/interim-invoice' => function (array $content) {
114✔
130
                return new Invoice($content);
×
131
            },
114✔
132
            'subscriptions/{subscriptionId}/upcoming-invoices' => function (array $content) {
114✔
133
                return new Collection(new Invoice(), $content);
×
134
            },
114✔
135
            'subscriptions/{subscriptionId}/upcoming-invoice' => function (array $content) {
114✔
136
                return new Invoice($content);
1✔
137
            },
114✔
138
            'subscriptions/{subscriptionId}/lead-source' => function (array $content) {
114✔
139
                return new LeadSource($content);
×
140
            },
114✔
141
            'subscription-pauses' => function (array $content) {
114✔
142
                return new Collection(new SubscriptionPause(), $content);
×
143
            },
114✔
144
            'subscription-pauses/{subscriptionPauseId}' => function (array $content) {
114✔
145
                return new SubscriptionPause($content);
×
146
            },
114✔
147
            'payment-cards' => function (array $content) {
114✔
148
                return new Collection(new PaymentCard(), $content);
1✔
149
            },
114✔
150
            'payment-cards/{cardId}' => function (array $content) {
114✔
151
                return new PaymentCard($content);
2✔
152
            },
114✔
153
            'paypal-accounts' => function (array $content) {
114✔
154
                return new Collection(new PayPalAccount(), $content);
1✔
155
            },
114✔
156
            'paypal-accounts/{paypalAccountId}' => function (array $content) {
114✔
157
                return new PayPalAccount($content);
2✔
158
            },
114✔
159
            'tokens' => function (array $content) {
114✔
160
                return new Collection(new PaymentToken(), $content);
1✔
161
            },
114✔
162
            'tokens/{tokenId}' => function (array $content) {
114✔
163
                return new PaymentToken($content);
2✔
164
            },
114✔
165
            'transactions' => function (array $content) {
114✔
166
                return new Collection(new Transaction(), $content);
1✔
167
            },
114✔
168
            'transactions/{transactionId}' => function (array $content) {
114✔
169
                return new Transaction($content);
3✔
170
            },
114✔
171
            'authentication-options' => function (array $content) {
114✔
172
                return new AuthenticationOptions($content);
1✔
173
            },
114✔
174
            'credentials' => function (array $content) {
114✔
175
                return new Collection(new CustomerCredential(), $content);
1✔
176
            },
114✔
177
            'credentials/{credentialId}' => function (array $content) {
114✔
178
                return new CustomerCredential($content);
1✔
179
            },
114✔
180
            'password-tokens' => function (array $content) {
114✔
181
                return new Collection(new ResetPasswordToken(), $content);
1✔
182
            },
114✔
183
            'password-tokens/{token}' => function (array $content) {
114✔
184
                return new ResetPasswordToken($content);
1✔
185
            },
114✔
186
            'authentication-tokens' => function (array $content) {
114✔
187
                return new Collection(new AuthenticationToken(), $content);
1✔
188
            },
114✔
189
            'authentication-tokens/{token}' => function (array $content) {
114✔
190
                return new AuthenticationToken($content);
2✔
191
            },
114✔
192
            'authentication-tokens/{token}/exchange' => function (array $content) {
114✔
193
                return new Session($content);
1✔
194
            },
114✔
195
            'organizations' => function (array $content) {
114✔
196
                return new Collection(new Organization(), $content);
1✔
197
            },
114✔
198
            'organizations/{organizationId}' => function (array $content) {
114✔
199
                return new Organization($content);
2✔
200
            },
114✔
201
            'custom-fields/{resourceType}' => function (array $content) {
114✔
202
                return new Collection(new CustomField(), $content);
1✔
203
            },
114✔
204
            'custom-fields/{resourceType}/{name}' => function (array $content) {
114✔
205
                return new CustomField($content);
1✔
206
            },
114✔
207
            'gateway-accounts' => function (array $content) {
114✔
208
                return new Collection(new GatewayAccount(), $content);
1✔
209
            },
114✔
210
            'gateway-accounts/{gatewayAccountId}' => function (array $content) {
114✔
211
                return new GatewayAccount($content);
1✔
212
            },
114✔
213
            'sessions/{sessionId}' => function (array $content) {
114✔
214
                return new Session($content);
×
215
            },
114✔
216
            'users' => function (array $content) {
114✔
217
                return new Collection(new User(), $content);
1✔
218
            },
114✔
219
            'users/{userId}' => function (array $content) {
114✔
220
                return new User($content);
2✔
221
            },
114✔
222
            'api-keys' => function (array $content) {
114✔
223
                return new Collection(new ApiKey(), $content);
1✔
224
            },
114✔
225
            'api-keys/{apiKeyId}' => function (array $content) {
114✔
226
                return new ApiKey($content);
1✔
227
            },
114✔
228
            'tracking/api' => function (array $content) {
114✔
229
                return new Collection(new ApiTracking(), $content);
1✔
230
            },
114✔
231
            'tracking/api/{logId}' => function (array $content) {
114✔
232
                return new ApiTracking($content);
1✔
233
            },
114✔
234
            'tracking/subscriptions' => function (array $content) {
114✔
235
                return new Collection(new SubscriptionTracking(), $content);
×
236
            },
114✔
237
            'tracking/subscriptions/{logId}' => function (array $content) {
114✔
238
                return new SubscriptionTracking($content);
×
239
            },
114✔
240
            'disputes' => function (array $content) {
114✔
241
                return new Collection(new Dispute(), $content);
1✔
242
            },
114✔
243
            'disputes/{disputeId}' => function (array $content) {
114✔
244
                return new Dispute($content);
1✔
245
            },
114✔
246
            'coupons' => function (array $content) {
114✔
247
                return new Collection(new Coupon(), $content);
1✔
248
            },
114✔
249
            'coupons/{couponId}' => function (array $content) {
114✔
250
                return new Coupon($content);
2✔
251
            },
114✔
252
            'coupons-redemptions' => function (array $content) {
114✔
253
                return new Collection(new Redemption(), $content);
1✔
254
            },
114✔
255
            'coupons-redemptions/{redemptionId}' => function (array $content) {
114✔
256
                return new Redemption($content);
2✔
257
            },
114✔
258
            'lists' => function (array $content) {
114✔
259
                return new Collection(new ValuesList(), $content);
1✔
260
            },
114✔
261
            'lists/{listId}' => function (array $content) {
114✔
262
                return new ValuesList($content);
2✔
263
            },
114✔
264
            'lists/{listId}/{version}' => function (array $content) {
114✔
265
                return new ValuesList($content);
×
266
            },
114✔
267
            'tracking/lists' => function (array $content) {
114✔
268
                return new Collection(new ValuesList(), $content);
1✔
269
            },
114✔
270
            'webhooks' => function (array $content) {
114✔
271
                return new Collection(new Webhook(), $content);
1✔
272
            },
114✔
273
            'webhooks/{webhookId}' => function (array $content) {
114✔
274
                return new Webhook($content);
1✔
275
            },
114✔
276
            'previews/webhooks' => function (array $content) {
114✔
277
                return new Webhook($content);
1✔
278
            },
114✔
279
            'service-credentials/webhook/{id}' => function (array $content) {
114✔
280
                return new WebhookCredential($content);
2✔
281
            },
114✔
282
            'tracking/webhooks' => function (array $content) {
114✔
283
                return new Collection(new WebhookTracking(), $content);
1✔
284
            },
114✔
285
            'tracking/webhooks/{webhookId}' => function (array $content) {
114✔
286
                return new WebhookTracking($content);
1✔
287
            },
114✔
288
            'gateway-accounts/{gatewayAccountId}/downtime-schedules' => function (array $content) {
114✔
289
                return new Collection(new GatewayAccountDowntime(), $content);
1✔
290
            },
114✔
291
            'gateway-accounts/{gatewayAccountId}/downtime-schedules/{downtimeId}' => function (array $content) {
114✔
292
                return new GatewayAccountDowntime($content);
1✔
293
            },
114✔
294
            'gateway-accounts/{gatewayAccountId}/limits' => function (array $content) {
114✔
295
                return new Collection(new GatewayAccountLimit(), $content);
1✔
296
            },
114✔
297
            'gateway-accounts/{gatewayAccountId}/limits/{limitId}' => function (array $content) {
114✔
298
                return new GatewayAccountLimit($content);
1✔
299
            },
114✔
300
            'subscription-cancellations' => function (array $content) {
114✔
301
                return new Collection(new SubscriptionCancellation(), $content);
1✔
302
            },
114✔
303
            'subscription-cancellations/{cancellationId}' => function (array $content) {
114✔
304
                return new SubscriptionCancellation($content);
2✔
305
            },
114✔
306
            'subscription-reactivations' => function (array $content) {
114✔
307
                return new Collection(new SubscriptionReactivation(), $content);
1✔
308
            },
114✔
309
            'subscription-reactivations/{reactivationId}' => function (array $content) {
114✔
310
                return new SubscriptionReactivation($content);
1✔
311
            },
114✔
312
            'kyc-documents' => function (array $content) {
114✔
313
                return new Collection(new KycDocument(), $content);
1✔
314
            },
114✔
315
            'kyc-documents/{id}' => function (array $content) {
114✔
316
                return new KycDocument($content);
1✔
317
            },
114✔
318
            'events/{eventType}/rules' => function (array $content) {
114✔
319
                return new EventRules($content);
1✔
320
            },
114✔
321
            'customers/{customerId}/timeline' => function (array $content) {
114✔
322
                return new Collection(new CustomerTimelineMessage(), $content);
1✔
323
            },
114✔
324
            'customers/{customerId}/timeline/{messageId}' => function (array $content) {
114✔
325
                return new CustomerTimelineMessage($content);
1✔
326
            },
114✔
327
            'aml' => function (array $content) {
114✔
328
                return new Collection(new AmlEntry(), $content);
×
329
            },
114✔
330
            'service-credentials/plaid/{id}' => function (array $content) {
114✔
331
                return new PlaidCredential($content);
1✔
332
            },
114✔
333
            'payment-instruments' => function (array $content) {
114✔
334
                return new Collection(new CommonPaymentInstrument(), $content);
1✔
335
            },
114✔
336
            'payment-instruments/{paymentInstrumentId}' => function (array $content) {
114✔
337
                return new CommonPaymentInstrument($content);
2✔
338
            },
114✔
339
            'service-credentials/experian' => function (array $content) {
114✔
340
                return new Collection(new ExperianCredential(), $content);
1✔
341
            },
114✔
342
            'service-credentials/experian/{id}' => function (array $content) {
114✔
343
                return new ExperianCredential($content);
1✔
344
            },
114✔
345
            'service-credentials/taxjar' => function (array $content) {
114✔
346
                return new Collection(new TaxJarCredential(), $content);
1✔
347
            },
114✔
348
            'service-credentials/taxjar/{id}' => function (array $content) {
114✔
349
                return new TaxJarCredential($content);
1✔
350
            },
114✔
351
            'tags' => function (array $content) {
114✔
352
                return new Collection(new Tag(), $content);
1✔
353
            },
114✔
354
            'tags/{tag}' => function (array $content) {
114✔
355
                return new Tag($content);
1✔
356
            },
114✔
357
            'previews/orders' => function (array $content) {
114✔
358
                return new PreviewOrder($content);
×
359
            },
114✔
360
            'ready-to-pay' => function (array $content) {
114✔
361
                return new Collection(new ReadyToPay(), $content);
×
362
            },
114✔
363
            'credit-memos' => function (array $content) {
114✔
364
                return new Collection(new CreditMemo(), $content);
1✔
365
            },
114✔
366
            'credit-memos/{creditMemoId}' => function (array $content) {
114✔
367
                return new CreditMemo($content);
2✔
368
            },
114✔
369
        ];
114✔
370
    }
371

372
    /**
373
     * {@inheritdoc}
374
     */
375
    public function getIterator(): ArrayIterator
376
    {
377
        return new ArrayIterator($this->builders);
114✔
378
    }
379

380
    /**
381
     * {@inheritdoc}
382
     */
383
    public function offsetExists($offset): bool
384
    {
385
        return isset($this->builders[$offset]);
×
386
    }
387

388
    /**
389
     * {@inheritdoc}
390
     */
391
    #[\ReturnTypeWillChange]
392
    public function offsetGet($offset)
393
    {
394
        return $this->builders[$offset];
78✔
395
    }
396

397
    /**
398
     * {@inheritdoc}
399
     */
400
    public function offsetSet($offset, $value): void
401
    {
402
        if (!is_callable($value)) {
×
403
            throw new InvalidArgumentException();
×
404
        }
405

406
        $this->builders[$offset] = $value;
×
407
    }
408

409
    /**
410
     * {@inheritdoc}
411
     */
412
    public function offsetUnset($offset): void
413
    {
414
        unset($this->builders[$offset]);
×
415
    }
416
}
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