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

stripe / stripe-php / 6471862601

10 Oct 2023 04:02PM UTC coverage: 69.665% (-0.5%) from 70.141%
6471862601

push

github

web-flow
Merge pull request #1570 from localheinz/feature/coveralls

Enhancement: Use `coverallsapp/github-action` to report code coverage

2393 of 3435 relevant lines covered (69.67%)

3.5 hits per line

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

0.0
/lib/Service/AbstractServiceFactory.php
1
<?php
2

3
namespace Stripe\Service;
4

5
/**
6
 * Abstract base class for all service factories used to expose service
7
 * instances through {@link \Stripe\StripeClient}.
8
 *
9
 * Service factories serve two purposes:
10
 *
11
 * 1. Expose properties for all services through the `__get()` magic method.
12
 * 2. Lazily initialize each service instance the first time the property for
13
 *    a given service is used.
14
 */
15
abstract class AbstractServiceFactory
16
{
17
    /** @var \Stripe\StripeClientInterface */
18
    private $client;
19

20
    /** @var array<string, AbstractService|AbstractServiceFactory> */
21
    private $services;
22

23
    /**
24
     * @param \Stripe\StripeClientInterface $client
25
     */
26
    public function __construct($client)
×
27
    {
28
        $this->client = $client;
×
29
        $this->services = [];
×
30
    }
31

32
    /**
33
     * @param string $name
34
     *
35
     * @return null|string
36
     */
37
    abstract protected function getServiceClass($name);
38

39
    /**
40
     * @param string $name
41
     *
42
     * @return null|AbstractService|AbstractServiceFactory
43
     */
44
    public function __get($name)
×
45
    {
46
        return $this->getService($name);
×
47
    }
48

49
    /**
50
     * @param string $name
51
     *
52
     * @return null|AbstractService|AbstractServiceFactory
53
     */
54
    public function getService($name)
×
55
    {
56
        $serviceClass = $this->getServiceClass($name);
×
57
        if (null !== $serviceClass) {
×
58
            if (!\array_key_exists($name, $this->services)) {
×
59
                $this->services[$name] = new $serviceClass($this->client);
×
60
            }
61

62
            return $this->services[$name];
×
63
        }
64

65
        \trigger_error('Undefined property: ' . static::class . '::$' . $name);
×
66

67
        return null;
×
68
    }
69
}
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