PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / vendor / wpfluent / framework / src / WPFluent / Foundation / App.php

App.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.5, at vendor/wpfluent/framework/src/WPFluent/Foundation/App.php

87 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\Framework\Foundation;
4
5 use FluentCart\Framework\Container\Contracts\BindingResolutionException;
6
7 /**
8 * @method static \FluentCart\Framework\Database\DatabaseManager db()
9 * @method static \FluentCart\Framework\View\View view()
10 * @method static \FluentCart\Framework\Events\Dispatcher events()
11 * @method static \FluentCart\Framework\Foundation\Config config()
12 * @method static \FluentCart\Framework\Http\Request\Request request()
13 * @method static \FluentCart\Framework\Http\Response\Response response()
14 * @method static \FluentCart\Framework\Encryption\Encrypter encrypter()
15 * @method static \FluentCart\Framework\Validator\Validator validator()
16 */
17 class App
18 {
19 /**
20 * Application instance
21 *
22 * @var \FluentCart\Framework\Foundation\Application
23 */
24 protected static $instance = null;
25
26 /**
27 * Set the application instance
28 *
29 * @param \FluentCart\Framework\Foundation\Application $app
30 */
31 public static function setInstance($app)
32 {
33 static::$instance = $app;
34 }
35
36 /**
37 * Get the application instance
38 *
39 * @param string $module The binding/key name for a component.
40 * @param array $parameters constructor dependencies if any.
41 * @return \FluentCart\Framework\Foundation\Application|mixed
42 */
43 public static function getInstance($module = null, $parameters = [])
44 {
45 if ($module) {
46 return static::$instance->make($module, $parameters);
47 }
48
49 return static::$instance;
50 }
51
52 /**
53 * Retrive a component from the container
54 *
55 * @param string $module The binding/key name for a component.
56 * @param array $parameters constructor dependencies if any.
57 * @return \FluentCart\Framework\Foundation\Application|mixed
58 */
59 public static function make($module = null, $parameters = [])
60 {
61 return static::getInstance($module, $parameters);
62 }
63
64 /**
65 * Handle dynamic method calls
66 *
67 * @param string $method
68 * @param array $params
69 * @return mixed
70 */
71 public static function __callStatic($method, $params)
72 {
73 if ($method === 'support') {
74 $param = array_splice($params, 0, 1);
75 return static::getInstance(
76 'Support.' . implode('.', $param), ...$params
77 );
78 }
79
80 if (method_exists(static::$instance, $method)) {
81 return static::$instance->{$method}(...$params);
82 }
83
84 return static::getInstance($method, ...$params);
85 }
86 }
87