PluginProbe
Depicter — Popup & Slider Builder / 1.3.3
Depicter — Popup & Slider Builder v1.3.3
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / htmlburger / wpemerge / src / Application / ApplicationTrait.php

ApplicationTrait.php in Depicter — Popup & Slider Builder 1.3.3, at vendor/htmlburger/wpemerge/src/Application/ApplicationTrait.php

79 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package WPEmerge
4 * @author Atanas Angelov <hi@atanas.dev>
5 * @copyright 2017-2019 Atanas Angelov
6 * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7 * @link https://wpemerge.com/
8 */
9
10 namespace WPEmerge\Application;
11
12 use WPEmerge\Exceptions\ConfigurationException;
13
14 /**
15 * Provides static access to an Application instance.
16 *
17 * @mixin ApplicationMixin
18 */
19 trait ApplicationTrait {
20 /**
21 * Application instance.
22 *
23 * @var Application|null
24 */
25 public static $instance = null;
26
27 /**
28 * Make and assign a new application instance.
29 *
30 * @return Application
31 */
32 public static function make() {
33 static::setApplication( Application::make() );
34
35 return static::getApplication();
36 }
37
38 /**
39 * Get the Application instance.
40 *
41 * @codeCoverageIgnore
42 * @return Application|null
43 */
44 public static function getApplication() {
45 return static::$instance;
46 }
47
48 /**
49 * Set the Application instance.
50 *
51 * @codeCoverageIgnore
52 * @param Application|null $application
53 * @return void
54 */
55 public static function setApplication( $application ) {
56 static::$instance = $application;
57 }
58
59 /**
60 * Invoke any matching instance method for the static method being called.
61 *
62 * @param string $method
63 * @param array $parameters
64 * @return mixed
65 */
66 public static function __callStatic( $method, $parameters ) {
67 $application = static::getApplication();
68
69 if ( ! $application ) {
70 throw new ConfigurationException(
71 'Application instance not created in ' . static::class . '. ' .
72 'Did you miss to call ' . static::class . '::make()?'
73 );
74 }
75
76 return call_user_func_array( [$application, $method], $parameters );
77 }
78 }
79