PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.3.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.3.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Container.php

Container.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.3.0, at src/Performance/Container.php

103 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * A local container mapping di52 methods to ContainerInterface.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 namespace SolidWP\Performance;
11
12 use SolidWP\Performance\StellarWP\ContainerContract\ContainerInterface;
13 use SolidWP\Performance\lucatume\DI52\Container as DI52Container;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * A local container implementation.
21 *
22 * @since 0.1.0
23 *
24 * @package SolidWP\Performance
25 *
26 * @method mixed getVar(string $key, mixed|null $default = null)
27 * @method void setVar(string $key, mixed $value)
28 * @method void register(string $serviceProviderClass, string ...$alias)
29 * @method self when(string $class)
30 * @method self needs(string $id)
31 * @method void give(mixed $implementation)
32 * @method void callback(string|object $id, string $method)
33 */
34 class Container implements ContainerInterface {
35
36 /**
37 * @since 0.1.0
38 *
39 * @var DI52Container
40 */
41 protected DI52Container $container;
42
43 /**
44 * Container constructor.
45 *
46 * @since 0.1.0
47 *
48 * @param DI52Container $container The container to use.
49 */
50 public function __construct( DI52Container $container ) {
51 $this->container = $container;
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function bind( string $id, $implementation = null, array $after_build_methods = null ) {
58 $this->container->bind( $id, $implementation, $after_build_methods );
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function get( string $id ) {
65 return $this->container->get( $id );
66 }
67
68 /**
69 * @since 0.1.0
70 *
71 * @return DI52Container
72 */
73 public function get_container() {
74 return $this->container;
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function has( string $id ) {
81 return $this->container->has( $id );
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function singleton( string $id, $implementation = null, array $after_build_methods = null ) {
88 $this->container->singleton( $id, $implementation, $after_build_methods );
89 }
90
91 /**
92 * Defer all other calls to the container object.
93 *
94 * @since 0.1.0
95 *
96 * @param string $name The name of the method to call.
97 * @param array $args The arguments to pass to the method.
98 */
99 public function __call( $name, $args ) {
100 return $this->container->{$name}( ...$args );
101 }
102 }
103