PluginProbe
WooCommerce / 11.1.0-rc.2
WooCommerce v11.1.0-rc.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Blocks / Registry / AbstractDependencyType.php
AbstractDependencyType.php
55 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Automattic\WooCommerce\Blocks\Registry;
3
4 /**
5 * An abstract class for dependency types.
6 *
7 * Dependency types are instances of a dependency used by the
8 * Dependency Injection Container for storing dependencies to invoke as they
9 * are needed.
10 *
11 * @since 2.5.0
12 */
13 abstract class AbstractDependencyType {
14
15 /**
16 * Holds a callable or value provided for this type.
17 *
18 * @var mixed
19 */
20 private $callable_or_value;
21
22 /**
23 * Constructor
24 *
25 * @param mixed $callable_or_value A callable or value for the dependency
26 * type instance.
27 */
28 public function __construct( $callable_or_value ) {
29 $this->callable_or_value = $callable_or_value;
30 }
31
32 /**
33 * Resolver for the internal dependency value.
34 *
35 * @param Container $container The Dependency Injection Container.
36 *
37 * @return mixed
38 */
39 protected function resolve_value( Container $container ) {
40 $callback = $this->callable_or_value;
41 return \is_callable( $callback )
42 ? $callback( $container )
43 : $callback;
44 }
45
46 /**
47 * Retrieves the value stored internally for this DependencyType
48 *
49 * @param Container $container The Dependency Injection Container.
50 *
51 * @return void
52 */
53 abstract public function get( Container $container );
54 }
55