PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.91.6
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.91.6
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / vendor / wpfluent / framework / src / WPFluent / Foundation / App.php

App.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.91.6, 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 FluentBoards\Framework\Foundation;
4
5 use FluentBoards\Framework\Container\Contracts\BindingResolutionException;
6
7 class App
8 {
9 /**
10 * Application instance
11 *
12 * @var FluentBoards\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 FluentBoards\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 FluentBoards\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 FluentBoards\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