PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
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 trunk, at src/Performance/Container.php

104 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 mixed callback(string|object $id, string $method)
33 * @method void offsetUnset(string $id)
34 */
35 class Container implements ContainerInterface {
36
37 /**
38 * @since 0.1.0
39 *
40 * @var DI52Container
41 */
42 protected DI52Container $container;
43
44 /**
45 * Container constructor.
46 *
47 * @since 0.1.0
48 *
49 * @param DI52Container $container The container to use.
50 */
51 public function __construct( DI52Container $container ) {
52 $this->container = $container;
53 }
54
55 /**
56 * {@inheritdoc}
57 */
58 public function bind( string $id, $implementation = null, array $after_build_methods = null ) {
59 $this->container->bind( $id, $implementation, $after_build_methods );
60 }
61
62 /**
63 * {@inheritdoc}
64 */
65 public function get( string $id ) {
66 return $this->container->get( $id );
67 }
68
69 /**
70 * @since 0.1.0
71 *
72 * @return DI52Container
73 */
74 public function get_container() {
75 return $this->container;
76 }
77
78 /**
79 * {@inheritdoc}
80 */
81 public function has( string $id ) {
82 return $this->container->has( $id );
83 }
84
85 /**
86 * {@inheritdoc}
87 */
88 public function singleton( string $id, $implementation = null, array $after_build_methods = null ) {
89 $this->container->singleton( $id, $implementation, $after_build_methods );
90 }
91
92 /**
93 * Defer all other calls to the container object.
94 *
95 * @since 0.1.0
96 *
97 * @param string $name The name of the method to call.
98 * @param array $args The arguments to pass to the method.
99 */
100 public function __call( $name, $args ) {
101 return $this->container->{$name}( ...$args );
102 }
103 }
104