PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.7.1
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.7.1
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
fluent-booking / vendor / wpfluent / framework / src / WPFluent / Foundation / App.php

App.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.7.1, at vendor/wpfluent/framework/src/WPFluent/Foundation/App.php

99 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\Framework\Foundation;
4
5 use FluentBooking\Framework\Container\Contracts\BindingResolutionException;
6
7 class App
8 {
9 /**
10 * Application instance
11 *
12 * @var FluentBooking\Framework\Foundation\Application
13 */
14 protected static $instance = null;
15
16 /**
17 * Resolve dynamically accessed class.
18 *
19 * @param string $module
20 * @return string
21 */
22 protected static function resolve($module)
23 {
24 $pieces = explode('\\', __NAMESPACE__);
25 array_pop($pieces) && $prefix = implode('\\', $pieces);
26 return $prefix . '\\' . str_replace('.', '\\', $module);
27 }
28
29 /**
30 * Set the application instance
31 *
32 * @param FluentBooking\Framework\Foundation\Application $app
33 */
34 public static function setInstance($app)
35 {
36 static::$instance = $app;
37 }
38
39 /**
40 * Get the application instance
41 *
42 * @param string $module The binding/key name for a component.
43 * @param array $parameters constructor dependencies if any.
44 * @return FluentBooking\Framework\Foundation\Application|mixed
45 */
46 public static function getInstance($module = null, $parameters = [])
47 {
48 try {
49 if ($module) {
50 return static::$instance->make($module, $parameters);
51 }
52
53 return static::$instance;
54
55 } catch (BindingResolutionException $e) {
56 if (class_exists($class = static::resolve($module))) {
57 return static::$instance->make($class, $parameters);
58 }
59
60 throw $e;
61 }
62 }
63
64 /**
65 * Retrive a component from the container
66 *
67 * @param string $module The binding/key name for a component.
68 * @param array $parameters constructor dependencies if any.
69 * @return FluentBooking\Framework\Foundation\Application|mixed
70 */
71 public static function make($module = null, $parameters = [])
72 {
73 return static::getInstance($module, $parameters);
74 }
75
76 /**
77 * Handle dynamic method calls
78 *
79 * @param string $method
80 * @param array $params
81 * @return mixed
82 */
83 public static function __callStatic($method, $params)
84 {
85 if ($method === 'support') {
86 $param = array_splice($params, 0, 1);
87 return static::getInstance(
88 'Support.' . implode('.', $param), ...$params
89 );
90 }
91
92 if (method_exists(static::$instance, $method)) {
93 return static::$instance->{$method}(...$params);
94 }
95
96 return static::getInstance($method, ...$params);
97 }
98 }
99