Completed
Push — master ( e15034...d41fc5 )
by James
08:34
created
src/Core/Application.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -13,138 +13,138 @@
 block discarded – undo
13 13
  * @package Intraxia\Jaxion
14 14
  */
15 15
 class Application extends Container implements ApplicationContract {
16
-	/**
17
-	 * Define plugin version on Application.
18
-	 */
19
-	const VERSION = '';
20
-
21
-	/**
22
-	 * Singleton instance of the Application object
23
-	 *
24
-	 * @var Application[]
25
-	 */
26
-	protected static $instances = array();
27
-
28
-	/**
29
-	 * Instantiates a new Application container.
30
-	 *
31
-	 * The Application constructor enforces the presence of of a single instance
32
-	 * of the Application. If an instance already exists, an Exception will be thrown.
33
-	 *
34
-	 * @param string $file
35
-	 * @param array  $providers
36
-	 *
37
-	 * @throws ApplicationAlreadyBootedException
38
-	 */
39
-	public function __construct( $file, array $providers = array() ) {
40
-		if ( isset( static::$instances[ get_called_class() ] ) ) {
41
-			throw new ApplicationAlreadyBootedException;
42
-		}
43
-
44
-		static::$instances[ get_called_class() ] = $this;
45
-
46
-		$this->register_constants( $file );
47
-		$this->register_core_services();
48
-
49
-		register_activation_hook( $file, array( $this, 'activate' ) );
50
-		register_deactivation_hook( $file, array( $this, 'deactivate' ) );
51
-
52
-		parent::__construct( $providers );
53
-	}
54
-
55
-	/**
56
-	 * {@inheritDoc}
57
-	 *
58
-	 * @throws UnexpectedValueException
59
-	 */
60
-	public function boot() {
61
-		$loader = $this->fetch( 'loader' );
62
-
63
-		if ( ! $loader instanceof LoaderContract ) {
64
-			throw new UnexpectedValueException;
65
-		}
66
-
67
-		foreach ( $this as $alias => $value ) {
68
-			if ( $value instanceof HasActions ) {
69
-				$loader->register_actions( $value );
70
-			}
71
-
72
-			if ( $value instanceof HasFilters ) {
73
-				$loader->register_filters( $value );
74
-			}
75
-
76
-			if ( $value instanceof HasShortcode ) {
77
-				$loader->register_shortcode( $value );
78
-			}
79
-		}
80
-
81
-		add_action( 'plugins_loaded', array( $loader, 'run' ) );
82
-	}
83
-
84
-	/**
85
-	 * {@inheritdoc}
86
-	 *
87
-	 * @codeCoverageIgnore
88
-	 */
89
-	public function activate() {
90
-		// no-op
91
-	}
92
-
93
-	/**
94
-	 * {@inheritdoc}
95
-	 *
96
-	 * @codeCoverageIgnore
97
-	 */
98
-	public function deactivate() {
99
-		// no-op
100
-	}
101
-
102
-	/**
103
-	 * {@inheritDoc}
104
-	 *
105
-	 * @return Application
106
-	 * @throws ApplicationNotBootedException
107
-	 */
108
-	public static function instance() {
109
-		if ( ! isset( static::$instances[ get_called_class() ] ) ) {
110
-			throw new ApplicationNotBootedException;
111
-		}
112
-
113
-		return static::$instances[ get_called_class() ];
114
-	}
115
-
116
-	/**
117
-	 * {@inheritDoc}
118
-	 */
119
-	public static function shutdown() {
120
-		if ( isset( static::$instances[ get_called_class() ] ) ) {
121
-			unset( static::$instances[ get_called_class() ] );
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * Sets the plugin's url, path, and basename.
127
-	 *
128
-	 * @param string $file
129
-	 */
130
-	private function register_constants( $file ) {
131
-		$this->share( 'file', $file );
132
-		$this->share( 'url', plugin_dir_url( $file ) );
133
-		$this->share( 'path', plugin_dir_path( $file ) );
134
-		$this->share( 'basename', $basename = plugin_basename( $file ) );
135
-		$this->share( 'slug', dirname( $basename ) );
136
-		$this->share( 'version', static::VERSION );
137
-	}
138
-
139
-	/**
140
-	 * Registers the built-in services with the Application container.
141
-	 */
142
-	private function register_core_services() {
143
-		$this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) {
144
-			return new Loader( $app );
145
-		} );
146
-		$this->share( array( 'i18n' => 'Intaxia\Jaxion\Contract\Core\I18n' ), function ( $app ) {
147
-			return new I18n( $app->fetch( 'basename' ), $app->fetch( 'path' ) );
148
-		} );
149
-	}
16
+    /**
17
+     * Define plugin version on Application.
18
+     */
19
+    const VERSION = '';
20
+
21
+    /**
22
+     * Singleton instance of the Application object
23
+     *
24
+     * @var Application[]
25
+     */
26
+    protected static $instances = array();
27
+
28
+    /**
29
+     * Instantiates a new Application container.
30
+     *
31
+     * The Application constructor enforces the presence of of a single instance
32
+     * of the Application. If an instance already exists, an Exception will be thrown.
33
+     *
34
+     * @param string $file
35
+     * @param array  $providers
36
+     *
37
+     * @throws ApplicationAlreadyBootedException
38
+     */
39
+    public function __construct( $file, array $providers = array() ) {
40
+        if ( isset( static::$instances[ get_called_class() ] ) ) {
41
+            throw new ApplicationAlreadyBootedException;
42
+        }
43
+
44
+        static::$instances[ get_called_class() ] = $this;
45
+
46
+        $this->register_constants( $file );
47
+        $this->register_core_services();
48
+
49
+        register_activation_hook( $file, array( $this, 'activate' ) );
50
+        register_deactivation_hook( $file, array( $this, 'deactivate' ) );
51
+
52
+        parent::__construct( $providers );
53
+    }
54
+
55
+    /**
56
+     * {@inheritDoc}
57
+     *
58
+     * @throws UnexpectedValueException
59
+     */
60
+    public function boot() {
61
+        $loader = $this->fetch( 'loader' );
62
+
63
+        if ( ! $loader instanceof LoaderContract ) {
64
+            throw new UnexpectedValueException;
65
+        }
66
+
67
+        foreach ( $this as $alias => $value ) {
68
+            if ( $value instanceof HasActions ) {
69
+                $loader->register_actions( $value );
70
+            }
71
+
72
+            if ( $value instanceof HasFilters ) {
73
+                $loader->register_filters( $value );
74
+            }
75
+
76
+            if ( $value instanceof HasShortcode ) {
77
+                $loader->register_shortcode( $value );
78
+            }
79
+        }
80
+
81
+        add_action( 'plugins_loaded', array( $loader, 'run' ) );
82
+    }
83
+
84
+    /**
85
+     * {@inheritdoc}
86
+     *
87
+     * @codeCoverageIgnore
88
+     */
89
+    public function activate() {
90
+        // no-op
91
+    }
92
+
93
+    /**
94
+     * {@inheritdoc}
95
+     *
96
+     * @codeCoverageIgnore
97
+     */
98
+    public function deactivate() {
99
+        // no-op
100
+    }
101
+
102
+    /**
103
+     * {@inheritDoc}
104
+     *
105
+     * @return Application
106
+     * @throws ApplicationNotBootedException
107
+     */
108
+    public static function instance() {
109
+        if ( ! isset( static::$instances[ get_called_class() ] ) ) {
110
+            throw new ApplicationNotBootedException;
111
+        }
112
+
113
+        return static::$instances[ get_called_class() ];
114
+    }
115
+
116
+    /**
117
+     * {@inheritDoc}
118
+     */
119
+    public static function shutdown() {
120
+        if ( isset( static::$instances[ get_called_class() ] ) ) {
121
+            unset( static::$instances[ get_called_class() ] );
122
+        }
123
+    }
124
+
125
+    /**
126
+     * Sets the plugin's url, path, and basename.
127
+     *
128
+     * @param string $file
129
+     */
130
+    private function register_constants( $file ) {
131
+        $this->share( 'file', $file );
132
+        $this->share( 'url', plugin_dir_url( $file ) );
133
+        $this->share( 'path', plugin_dir_path( $file ) );
134
+        $this->share( 'basename', $basename = plugin_basename( $file ) );
135
+        $this->share( 'slug', dirname( $basename ) );
136
+        $this->share( 'version', static::VERSION );
137
+    }
138
+
139
+    /**
140
+     * Registers the built-in services with the Application container.
141
+     */
142
+    private function register_core_services() {
143
+        $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) {
144
+            return new Loader( $app );
145
+        } );
146
+        $this->share( array( 'i18n' => 'Intaxia\Jaxion\Contract\Core\I18n' ), function ( $app ) {
147
+            return new I18n( $app->fetch( 'basename' ), $app->fetch( 'path' ) );
148
+        } );
149
+    }
150 150
 }
Please login to merge, or discard this patch.