PluginProbe
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe / trunk
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe vtrunk
4.17.3 trunk 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 4.10.0 4.11.1 4.12.2 4.14.1 4.14.2 4.14.3 4.15.0 4.16.0 All 59 releases
stripe / src / AbstractPluginServiceProvider.php

AbstractPluginServiceProvider.php in Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe trunk, at src/AbstractPluginServiceProvider.php

112 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin: Service provider abstract
4 *
5 * @package SimplePay
6 * @subpackage Core
7 * @copyright Copyright (c) 2022, Sandhills Development, LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 4.4.0
10 */
11
12 namespace SimplePay\Core;
13
14 use SimplePay\Vendor\League\Container\ServiceProvider\AbstractServiceProvider;
15
16 /**
17 * AbstractPluginServiceProvider class.
18 *
19 * @since 4.4.0
20 */
21 abstract class AbstractPluginServiceProvider extends AbstractServiceProvider {
22
23 /**
24 * Works around Container 2.x looking in $this->provides property.
25 *
26 * Once we can use Container 4.x we can simply override ::provides().
27 *
28 * @todo Remove when using Container 4.x
29 * @since 4.4.0
30 *
31 * @param string $property Property name to retrieve.
32 * @return mixed
33 */
34 public function __get( $property ) {
35 switch ( $property ) {
36 // Retrieves a merged list of services and subscribers.
37 case 'provides':
38 return $this->get_provides();
39 default:
40 return $this->$property;
41 }
42 }
43
44 /**
45 * Returns a list of services and subscribers that are provided.
46 *
47 * @since 4.4.0
48 *
49 * @return string[]
50 */
51 private function get_provides() {
52 return array_merge(
53 $this->get_services(),
54 $this->get_subscribers()
55 );
56 }
57
58 /**
59 * {@inheritdoc}
60 *
61 * @return bool|string[]
62 */
63 public function provides( $id = null ) {
64 $provides = $this->get_provides();
65
66 // @todo Remove when using Container 4.x.
67 if ( null === $id ) {
68 return $provides;
69 }
70
71 return in_array( $id, $provides, true );
72 }
73
74 /**
75 * Returns a list of services the service provider provides.
76 *
77 * @since 4.4.0
78 *
79 * @return string[]
80 */
81 abstract public function get_services();
82
83 /**
84 * Returns a list of subscribers the service provider provides.
85 *
86 * A subscriber is a subset of a standard service that is automatically resolved
87 * during each request. These are used for the WordPress plugin API.
88 *
89 * @since 4.4.0
90 *
91 * @return string[]
92 */
93 abstract public function get_subscribers();
94
95 /**
96 * Returns a list of child service providers.
97 *
98 * @since 4.4.3
99 *
100 * @return array<\SimplePay\Core\AbstractPluginServiceProvider>
101 */
102 public function get_service_providers() {
103 return array();
104 }
105
106 /**
107 * {@inheritdoc}
108 */
109 abstract public function register();
110
111 }
112