Completed
Pull Request — master (#19)
by James
08:05
created
src/Core/ConfigType.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 use MyCLabs\Enum\Enum;
5 5
 
6 6
 class ConfigType extends Enum {
7
-	const PLUGIN = 'plugin';
8
-	const THEME = 'theme';
9
-	const MU_PLUGIN = 'mu-plugin';
7
+    const PLUGIN = 'plugin';
8
+    const THEME = 'theme';
9
+    const MU_PLUGIN = 'mu-plugin';
10 10
 }
Please login to merge, or discard this patch.
src/Core/Application.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -13,155 +13,155 @@
 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 Config $config
35
-	 * @param array  $providers
36
-	 *
37
-	 * @throws ApplicationAlreadyBootedException
38
-	 */
39
-	public function __construct( $config, 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
-		if ( ! ( $config instanceof Config ) ) {
47
-			$config = new Config( ConfigType::PLUGIN, $config );
48
-		}
49
-
50
-		$this->register_constants( $config );
51
-		$this->register_core_services( $config );
52
-
53
-		register_activation_hook( $config->file, array( $this, 'activate' ) );
54
-		register_deactivation_hook( $config->file, array( $this, 'deactivate' ) );
55
-
56
-		parent::__construct( $providers );
57
-	}
58
-
59
-	/**
60
-	 * {@inheritDoc}
61
-	 *
62
-	 * @throws UnexpectedValueException
63
-	 */
64
-	public function boot() {
65
-		$loader = $this->fetch( 'loader' );
66
-
67
-		if ( ! ( $loader instanceof LoaderContract ) ) {
68
-			throw new UnexpectedValueException;
69
-		}
70
-
71
-		foreach ( $this as $alias => $value ) {
72
-			if ( $value instanceof HasActions ) {
73
-				$loader->register_actions( $value );
74
-			}
75
-
76
-			if ( $value instanceof HasFilters ) {
77
-				$loader->register_filters( $value );
78
-			}
79
-
80
-			if ( $value instanceof HasShortcode ) {
81
-				$loader->register_shortcode( $value );
82
-			}
83
-		}
84
-
85
-		add_action( 'plugins_loaded', array( $loader, 'run' ) );
86
-	}
87
-
88
-	/**
89
-	 * {@inheritdoc}
90
-	 *
91
-	 * @codeCoverageIgnore
92
-	 */
93
-	public function activate() {
94
-		// no-op
95
-	}
96
-
97
-	/**
98
-	 * {@inheritdoc}
99
-	 *
100
-	 * @codeCoverageIgnore
101
-	 */
102
-	public function deactivate() {
103
-		// no-op
104
-	}
105
-
106
-	/**
107
-	 * {@inheritDoc}
108
-	 *
109
-	 * @return Application
110
-	 * @throws ApplicationNotBootedException
111
-	 */
112
-	public static function instance() {
113
-		if ( ! isset( static::$instances[ get_called_class() ] ) ) {
114
-			throw new ApplicationNotBootedException;
115
-		}
116
-
117
-		return static::$instances[ get_called_class() ];
118
-	}
119
-
120
-	/**
121
-	 * {@inheritDoc}
122
-	 */
123
-	public static function shutdown() {
124
-		if ( isset( static::$instances[ get_called_class() ] ) ) {
125
-			unset( static::$instances[ get_called_class() ] );
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Sets the plugin's url, path, and basename.
131
-	 *
132
-	 * @param Config $config
133
-	 */
134
-	private function register_constants( Config $config ) {
135
-		$this->share( 'file', function() use ( $config ) {
136
-			return $config->file;
137
-		} );
138
-		$this->share( 'url', function() use ( $config ) {
139
-			return $config->url;
140
-		} );
141
-		$this->share( 'path', function() use ( $config ) {
142
-			return $config->path;
143
-		} );
144
-		$this->share( 'basename', function() use ( $config ) {
145
-			return $config->basename;
146
-		} );
147
-		$this->share( 'slug', function() use ( $config ) {
148
-			return $config->slug;
149
-		} );
150
-		$this->share( 'version', static::VERSION );
151
-	}
152
-
153
-	/**
154
-	 * Registers the built-in services with the Application container.
155
-	 *
156
-	 * @param Config $config
157
-	 */
158
-	private function register_core_services( Config $config ) {
159
-		$this->share( array( 'config' => 'Intraxia\Jaxion\Core\Config'), $config );
160
-		$this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function () {
161
-			return new Loader;
162
-		} );
163
-		$this->share( array( 'i18n' => 'Intaxia\Jaxion\Contract\Core\I18n' ), function ( Container $app ) {
164
-			return new I18n( $app->fetch( 'basename' ), $app->fetch( 'path' ) );
165
-		} );
166
-	}
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 Config $config
35
+     * @param array  $providers
36
+     *
37
+     * @throws ApplicationAlreadyBootedException
38
+     */
39
+    public function __construct( $config, 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
+        if ( ! ( $config instanceof Config ) ) {
47
+            $config = new Config( ConfigType::PLUGIN, $config );
48
+        }
49
+
50
+        $this->register_constants( $config );
51
+        $this->register_core_services( $config );
52
+
53
+        register_activation_hook( $config->file, array( $this, 'activate' ) );
54
+        register_deactivation_hook( $config->file, array( $this, 'deactivate' ) );
55
+
56
+        parent::__construct( $providers );
57
+    }
58
+
59
+    /**
60
+     * {@inheritDoc}
61
+     *
62
+     * @throws UnexpectedValueException
63
+     */
64
+    public function boot() {
65
+        $loader = $this->fetch( 'loader' );
66
+
67
+        if ( ! ( $loader instanceof LoaderContract ) ) {
68
+            throw new UnexpectedValueException;
69
+        }
70
+
71
+        foreach ( $this as $alias => $value ) {
72
+            if ( $value instanceof HasActions ) {
73
+                $loader->register_actions( $value );
74
+            }
75
+
76
+            if ( $value instanceof HasFilters ) {
77
+                $loader->register_filters( $value );
78
+            }
79
+
80
+            if ( $value instanceof HasShortcode ) {
81
+                $loader->register_shortcode( $value );
82
+            }
83
+        }
84
+
85
+        add_action( 'plugins_loaded', array( $loader, 'run' ) );
86
+    }
87
+
88
+    /**
89
+     * {@inheritdoc}
90
+     *
91
+     * @codeCoverageIgnore
92
+     */
93
+    public function activate() {
94
+        // no-op
95
+    }
96
+
97
+    /**
98
+     * {@inheritdoc}
99
+     *
100
+     * @codeCoverageIgnore
101
+     */
102
+    public function deactivate() {
103
+        // no-op
104
+    }
105
+
106
+    /**
107
+     * {@inheritDoc}
108
+     *
109
+     * @return Application
110
+     * @throws ApplicationNotBootedException
111
+     */
112
+    public static function instance() {
113
+        if ( ! isset( static::$instances[ get_called_class() ] ) ) {
114
+            throw new ApplicationNotBootedException;
115
+        }
116
+
117
+        return static::$instances[ get_called_class() ];
118
+    }
119
+
120
+    /**
121
+     * {@inheritDoc}
122
+     */
123
+    public static function shutdown() {
124
+        if ( isset( static::$instances[ get_called_class() ] ) ) {
125
+            unset( static::$instances[ get_called_class() ] );
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Sets the plugin's url, path, and basename.
131
+     *
132
+     * @param Config $config
133
+     */
134
+    private function register_constants( Config $config ) {
135
+        $this->share( 'file', function() use ( $config ) {
136
+            return $config->file;
137
+        } );
138
+        $this->share( 'url', function() use ( $config ) {
139
+            return $config->url;
140
+        } );
141
+        $this->share( 'path', function() use ( $config ) {
142
+            return $config->path;
143
+        } );
144
+        $this->share( 'basename', function() use ( $config ) {
145
+            return $config->basename;
146
+        } );
147
+        $this->share( 'slug', function() use ( $config ) {
148
+            return $config->slug;
149
+        } );
150
+        $this->share( 'version', static::VERSION );
151
+    }
152
+
153
+    /**
154
+     * Registers the built-in services with the Application container.
155
+     *
156
+     * @param Config $config
157
+     */
158
+    private function register_core_services( Config $config ) {
159
+        $this->share( array( 'config' => 'Intraxia\Jaxion\Core\Config'), $config );
160
+        $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function () {
161
+            return new Loader;
162
+        } );
163
+        $this->share( array( 'i18n' => 'Intaxia\Jaxion\Contract\Core\I18n' ), function ( Container $app ) {
164
+            return new I18n( $app->fetch( 'basename' ), $app->fetch( 'path' ) );
165
+        } );
166
+    }
167 167
 }
Please login to merge, or discard this patch.
src/Core/Config.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -2,98 +2,98 @@
 block discarded – undo
2 2
 namespace Intraxia\Jaxion\Core;
3 3
 
4 4
 class Config {
5
-	/**
6
-	 * Configuration type.
7
-	 *
8
-	 * @var ConfigType
9
-	 */
10
-	public $type;
5
+    /**
6
+     * Configuration type.
7
+     *
8
+     * @var ConfigType
9
+     */
10
+    public $type;
11 11
 
12
-	/**
13
-	 * App entry file.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $file;
12
+    /**
13
+     * App entry file.
14
+     *
15
+     * @var string
16
+     */
17
+    public $file;
18 18
 
19
-	/**
20
-	 * App url.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	public $url;
19
+    /**
20
+     * App url.
21
+     *
22
+     * @var string
23
+     */
24
+    public $url;
25 25
 
26
-	/**
27
-	 * App path.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	public $path;
26
+    /**
27
+     * App path.
28
+     *
29
+     * @var string
30
+     */
31
+    public $path;
32 32
 
33
-	/**
34
-	 * App slug.
35
-	 *
36
-	 * @var string
37
-	 */
38
-	public $slug;
33
+    /**
34
+     * App slug.
35
+     *
36
+     * @var string
37
+     */
38
+    public $slug;
39 39
 
40
-	/**
41
-	 * App basename.
42
-	 *
43
-	 * @var string
44
-	 */
45
-	public $basename;
40
+    /**
41
+     * App basename.
42
+     *
43
+     * @var string
44
+     */
45
+    public $basename;
46 46
 
47
-	/**
48
-	 * Loaded configuration files.
49
-	 *
50
-	 * @var array
51
-	 */
52
-	private $loaded = array();
47
+    /**
48
+     * Loaded configuration files.
49
+     *
50
+     * @var array
51
+     */
52
+    private $loaded = array();
53 53
 
54
-	/**
55
-	 * Config constructor.
56
-	 *
57
-	 * @param string $type
58
-	 * @param string $file
59
-	 */
60
-	public function __construct( $type, $file ) {
61
-		$this->type = new ConfigType( $type );
62
-		$this->file = $file;
54
+    /**
55
+     * Config constructor.
56
+     *
57
+     * @param string $type
58
+     * @param string $file
59
+     */
60
+    public function __construct( $type, $file ) {
61
+        $this->type = new ConfigType( $type );
62
+        $this->file = $file;
63 63
 
64
-		switch ( $this->type->getValue() ) {
65
-			case ConfigType::PLUGIN:
66
-			case ConfigType::MU_PLUGIN:
67
-				$this->url = plugin_dir_url( $file );
68
-				$this->path = plugin_dir_path( $file );
69
-				$this->slug = dirname( $this->basename = plugin_basename( $file ) );
70
-				break;
71
-			case ConfigType::THEME:
72
-				$this->url = get_stylesheet_directory_uri() . '/';
73
-				$this->path = get_stylesheet_directory() . '/';
74
-				$this->slug = dirname( $this->basename = plugin_basename( $file ) );
75
-				break;
76
-		}
77
-	}
64
+        switch ( $this->type->getValue() ) {
65
+            case ConfigType::PLUGIN:
66
+            case ConfigType::MU_PLUGIN:
67
+                $this->url = plugin_dir_url( $file );
68
+                $this->path = plugin_dir_path( $file );
69
+                $this->slug = dirname( $this->basename = plugin_basename( $file ) );
70
+                break;
71
+            case ConfigType::THEME:
72
+                $this->url = get_stylesheet_directory_uri() . '/';
73
+                $this->path = get_stylesheet_directory() . '/';
74
+                $this->slug = dirname( $this->basename = plugin_basename( $file ) );
75
+                break;
76
+        }
77
+    }
78 78
 
79
-	/**
80
-	 * Load a configuration JSON file from the config folder.
81
-	 *
82
-	 * @param string $filename
83
-	 *
84
-	 * @return array|null
85
-	 */
86
-	public function get_config_json( $filename ) {
87
-		if ( isset( $this->loaded[ $filename ] ) ) {
88
-			return $this->loaded[ $filename ];
89
-		}
79
+    /**
80
+     * Load a configuration JSON file from the config folder.
81
+     *
82
+     * @param string $filename
83
+     *
84
+     * @return array|null
85
+     */
86
+    public function get_config_json( $filename ) {
87
+        if ( isset( $this->loaded[ $filename ] ) ) {
88
+            return $this->loaded[ $filename ];
89
+        }
90 90
 
91
-		$contents = file_get_contents( $this->path . 'config/' . $filename . '.json' );
91
+        $contents = file_get_contents( $this->path . 'config/' . $filename . '.json' );
92 92
 
93
-		if ( $contents === false ) {
94
-			return null;
95
-		}
93
+        if ( $contents === false ) {
94
+            return null;
95
+        }
96 96
 
97
-		return $this->loaded[ $filename ] = json_decode( $contents, true );
98
-	}
97
+        return $this->loaded[ $filename ] = json_decode( $contents, true );
98
+    }
99 99
 }
Please login to merge, or discard this patch.