PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.3
Booktics – Appointment Booking Calendar for Service Businesses v1.0.3
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / trunk / vendor / stripe / stripe-php / lib / Service / AbstractServiceFactory.php

AbstractServiceFactory.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.3, at trunk/vendor/stripe/stripe-php/lib/Service/AbstractServiceFactory.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $serviceClass = $this->getServiceClass($name);
47 if (null !== $serviceClass) {
48 if (!\array_key_exists($name, $this->services)) {
49 $this->services[$name] = new $serviceClass($this->client);
50 }
51
52 return $this->services[$name];
53 }
54
55 \trigger_error('Undefined property: ' . static::class . '::$' . $name);
56
57 return null;
58 }
59 }
60