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

stripe / stripe-php / 11076452927

27 Sep 2024 07:17PM UTC coverage: 62.403% (-0.8%) from 63.204%
11076452927

push

github

web-flow
Adding support for the new Usage Billing APIs (#1750)

180 of 373 new or added lines in 21 files covered. (48.26%)

3 existing lines in 3 files now uncovered.

3552 of 5692 relevant lines covered (62.4%)

2.45 hits per line

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

0.0
/lib/V2/ThinEvent.php
1
<?php
2

3
namespace Stripe\V2;
4

5
use Stripe\StripeObject;
6
use Stripe\Util\Util;
7

8
/**
9
 * @property string $id Unique identifier for the event.
10
 * @property string $object String representing the object's type. Objects of the same type share the same value of the object field.
11
 * @property int $created Time at which the object was created.
12
 * @property \Stripe\StripeObject $reason Reason for the event.
13
 * @property \Stripe\StripeObject $related_object Object containing the reference to API resource relevant to the event.
14
 * @property string $type The type of the event.
15
 */
16
abstract class ThinEvent extends \Stripe\ApiResource
17
{
18
    const OBJECT_NAME = 'event';
19

20
    abstract public function fetchData();
21

22
    /**
23
     * Fetches the object related to the event from Stripe.
24
     * This fetches the latest state of the object to avoid issues like race conditions.
25
     *
26
     * @throws \Stripe\Exception\ApiErrorException
27
     *
28
     * @return null|array|StripeObject
29
     */
NEW
30
    public function fetchObject()
×
31
    {
32
        // @phpstan-ignore-next-line
NEW
33
        if (null === $this->related_object || null === $this->related_object->url) {
×
NEW
34
            return null;
×
35
        }
NEW
36
        list($object, $options) = $this->_request(
×
NEW
37
            'get',
×
38
            // @phpstan-ignore-next-line
NEW
39
            $this->related_object->url,
×
NEW
40
            [],
×
NEW
41
            null,
×
NEW
42
            [],
×
NEW
43
            'v2'
×
NEW
44
        );
×
45

NEW
46
        return Util::convertToStripeObject($object, $options, 'v2');
×
47
    }
48

49
    /**
50
     * Utility method to fetch event data from Stripe and convert it into a typed notification event.
51
     *
52
     * @param mixed $class
53
     *
54
     * @throws \Stripe\Exception\ApiErrorException
55
     *
56
     * @return StripeObject
57
     */
NEW
58
    public function fetchDataAndDeserialize($class)
×
59
    {
NEW
60
        list($fullEvent, $options) = $this->_request(
×
NEW
61
            'get',
×
NEW
62
            '/v2/events/' . $this->id,
×
NEW
63
            [],
×
NEW
64
            null,
×
NEW
65
            [],
×
NEW
66
            'v2'
×
NEW
67
        );
×
68

NEW
69
        return $class::constructFrom($fullEvent['data'], $options, 'v2');
×
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