PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 1.0.99
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v1.0.99
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
fluent-community / vendor / wpfluent / framework / src / WPFluent / Foundation / App.php

App.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 1.0.99, 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 FluentCommunity\Framework\Foundation;
4
5 use FluentCommunity\Framework\Container\Contracts\BindingResolutionException;
6
7 class App
8 {
9 /**
10 * Application instance
11 *
12 * @var FluentCommunity\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 FluentCommunity\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 FluentCommunity\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 FluentCommunity\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