@@ -4,7 +4,6 @@  | 
                                                    ||
| 4 | 4 | use Intraxia\Jaxion\Contract\Core\HasActions;  | 
                                                        
| 5 | 5 | use Intraxia\Jaxion\Contract\Core\HasFilters;  | 
                                                        
| 6 | 6 | use Intraxia\Jaxion\Contract\Core\Loader as LoaderContract;  | 
                                                        
| 7 | -use WP_CLI;  | 
                                                        |
| 8 | 7 | |
| 9 | 8 | /**  | 
                                                        
| 10 | 9 | * Class Application  | 
                                                        
@@ -11,132 +11,132 @@  | 
                                                    ||
| 11 | 11 | * @package Intraxia\Jaxion  | 
                                                        
| 12 | 12 | */  | 
                                                        
| 13 | 13 |  class Application extends Container implements ApplicationContract { | 
                                                        
| 14 | - /**  | 
                                                        |
| 15 | - * Singleton instance of the Application object  | 
                                                        |
| 16 | - *  | 
                                                        |
| 17 | - * @var Application  | 
                                                        |
| 18 | - */  | 
                                                        |
| 19 | - protected static $instance = null;  | 
                                                        |
| 20 | -  | 
                                                        |
| 21 | - /**  | 
                                                        |
| 22 | -	 * {@inheritdoc} | 
                                                        |
| 23 | - *  | 
                                                        |
| 24 | - * @param string $file  | 
                                                        |
| 25 | - * @param array $providers  | 
                                                        |
| 26 | - *  | 
                                                        |
| 27 | - * @throws ApplicationAlreadyBootedException  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | -	public function __construct( $file, array $providers = array() ) { | 
                                                        |
| 30 | -		if ( static::$instance !== null ) { | 
                                                        |
| 31 | - throw new ApplicationAlreadyBootedException;  | 
                                                        |
| 32 | - }  | 
                                                        |
| 33 | -  | 
                                                        |
| 34 | - static::$instance = $this;  | 
                                                        |
| 35 | -  | 
                                                        |
| 36 | - parent::__construct( $providers );  | 
                                                        |
| 37 | - $this->register_constants( $file );  | 
                                                        |
| 38 | - $this->register_core_services();  | 
                                                        |
| 39 | - $this->load_i18n();  | 
                                                        |
| 40 | -  | 
                                                        |
| 41 | - register_activation_hook( $file, array( $this, 'activate' ) );  | 
                                                        |
| 42 | - register_deactivation_hook( $file, array( $this, 'deactivate' ) );  | 
                                                        |
| 43 | - }  | 
                                                        |
| 44 | -  | 
                                                        |
| 45 | - /**  | 
                                                        |
| 46 | -	 * {@inheritDoc} | 
                                                        |
| 47 | - */  | 
                                                        |
| 48 | -	public function boot() { | 
                                                        |
| 49 | - $loader = $this->fetch( 'loader' );  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | -		if ( ! $loader instanceof LoaderContract ) { | 
                                                        |
| 52 | - throw new \UnexpectedValueException;  | 
                                                        |
| 53 | - }  | 
                                                        |
| 54 | -  | 
                                                        |
| 55 | -		foreach ( $this as $alias => $value ) { | 
                                                        |
| 56 | -			if ( $value instanceof HasActions ) { | 
                                                        |
| 57 | - $loader->register_actions( $value );  | 
                                                        |
| 58 | - }  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | -			if ( $value instanceof HasFilters ) { | 
                                                        |
| 61 | - $loader->register_filters( $value );  | 
                                                        |
| 62 | - }  | 
                                                        |
| 63 | - }  | 
                                                        |
| 64 | -  | 
                                                        |
| 65 | - add_action( 'plugins_loaded', array( $loader, 'run' ) );  | 
                                                        |
| 66 | - }  | 
                                                        |
| 67 | -  | 
                                                        |
| 68 | - /**  | 
                                                        |
| 69 | -	 * {@inheritdoc} | 
                                                        |
| 70 | - *  | 
                                                        |
| 71 | - * @codeCoverageIgnore  | 
                                                        |
| 72 | - */  | 
                                                        |
| 73 | -	public function activate() { | 
                                                        |
| 74 | - // no-op  | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | - /**  | 
                                                        |
| 78 | -	 * {@inheritdoc} | 
                                                        |
| 79 | - *  | 
                                                        |
| 80 | - * @codeCoverageIgnore  | 
                                                        |
| 81 | - */  | 
                                                        |
| 82 | -	public function deactivate() { | 
                                                        |
| 83 | - // no-op  | 
                                                        |
| 84 | - }  | 
                                                        |
| 85 | -  | 
                                                        |
| 86 | - /**  | 
                                                        |
| 87 | -	 * {@inheritDoc} | 
                                                        |
| 88 | - *  | 
                                                        |
| 89 | - * @return Application  | 
                                                        |
| 90 | - * @throws ApplicationNotBootedException  | 
                                                        |
| 91 | - */  | 
                                                        |
| 92 | -	public static function instance() { | 
                                                        |
| 93 | -		if ( static::$instance === null ) { | 
                                                        |
| 94 | - throw new ApplicationNotBootedException;  | 
                                                        |
| 95 | - }  | 
                                                        |
| 96 | -  | 
                                                        |
| 97 | - return static::$instance;  | 
                                                        |
| 98 | - }  | 
                                                        |
| 99 | -  | 
                                                        |
| 100 | - /**  | 
                                                        |
| 101 | -	 * {@inheritDoc} | 
                                                        |
| 102 | - */  | 
                                                        |
| 103 | -	public static function shutdown() { | 
                                                        |
| 104 | -		if ( static::$instance !== null ) { | 
                                                        |
| 105 | - static::$instance = null;  | 
                                                        |
| 106 | - }  | 
                                                        |
| 107 | - }  | 
                                                        |
| 108 | -  | 
                                                        |
| 109 | - /**  | 
                                                        |
| 110 | - * Sets the plugin's url, path, and basename.  | 
                                                        |
| 111 | - *  | 
                                                        |
| 112 | - * @param string $file  | 
                                                        |
| 113 | - */  | 
                                                        |
| 114 | -	private function register_constants( $file ) { | 
                                                        |
| 115 | - $this->share( 'url', plugin_dir_url( $file ) );  | 
                                                        |
| 116 | - $this->share( 'path', plugin_dir_path( $file ) );  | 
                                                        |
| 117 | - $this->share( 'basename', plugin_basename( $file ) );  | 
                                                        |
| 118 | -  | 
                                                        |
| 119 | - $plugin_data = get_plugin_data( $file, false, false );  | 
                                                        |
| 120 | - $this->share( 'version', isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : null );  | 
                                                        |
| 121 | - }  | 
                                                        |
| 122 | -  | 
                                                        |
| 123 | - /**  | 
                                                        |
| 124 | - * Registers the built-in services with the Application container.  | 
                                                        |
| 125 | - */  | 
                                                        |
| 126 | -	private function register_core_services() { | 
                                                        |
| 127 | -		$this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { | 
                                                        |
| 128 | - return new Loader( $app );  | 
                                                        |
| 129 | - } );  | 
                                                        |
| 130 | - }  | 
                                                        |
| 131 | -  | 
                                                        |
| 132 | - /**  | 
                                                        |
| 133 | - * Load's the plugin's translation files.  | 
                                                        |
| 134 | - */  | 
                                                        |
| 135 | -	private function load_i18n() { | 
                                                        |
| 136 | - load_plugin_textdomain(  | 
                                                        |
| 137 | - $this->fetch( 'basename' ),  | 
                                                        |
| 138 | - false,  | 
                                                        |
| 139 | - basename( $this->fetch( 'path' ) ) . '/languages/'  | 
                                                        |
| 140 | - );  | 
                                                        |
| 141 | - }  | 
                                                        |
| 14 | + /**  | 
                                                        |
| 15 | + * Singleton instance of the Application object  | 
                                                        |
| 16 | + *  | 
                                                        |
| 17 | + * @var Application  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | + protected static $instance = null;  | 
                                                        |
| 20 | +  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | +     * {@inheritdoc} | 
                                                        |
| 23 | + *  | 
                                                        |
| 24 | + * @param string $file  | 
                                                        |
| 25 | + * @param array $providers  | 
                                                        |
| 26 | + *  | 
                                                        |
| 27 | + * @throws ApplicationAlreadyBootedException  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | +    public function __construct( $file, array $providers = array() ) { | 
                                                        |
| 30 | +        if ( static::$instance !== null ) { | 
                                                        |
| 31 | + throw new ApplicationAlreadyBootedException;  | 
                                                        |
| 32 | + }  | 
                                                        |
| 33 | +  | 
                                                        |
| 34 | + static::$instance = $this;  | 
                                                        |
| 35 | +  | 
                                                        |
| 36 | + parent::__construct( $providers );  | 
                                                        |
| 37 | + $this->register_constants( $file );  | 
                                                        |
| 38 | + $this->register_core_services();  | 
                                                        |
| 39 | + $this->load_i18n();  | 
                                                        |
| 40 | +  | 
                                                        |
| 41 | + register_activation_hook( $file, array( $this, 'activate' ) );  | 
                                                        |
| 42 | + register_deactivation_hook( $file, array( $this, 'deactivate' ) );  | 
                                                        |
| 43 | + }  | 
                                                        |
| 44 | +  | 
                                                        |
| 45 | + /**  | 
                                                        |
| 46 | +     * {@inheritDoc} | 
                                                        |
| 47 | + */  | 
                                                        |
| 48 | +    public function boot() { | 
                                                        |
| 49 | + $loader = $this->fetch( 'loader' );  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | +        if ( ! $loader instanceof LoaderContract ) { | 
                                                        |
| 52 | + throw new \UnexpectedValueException;  | 
                                                        |
| 53 | + }  | 
                                                        |
| 54 | +  | 
                                                        |
| 55 | +        foreach ( $this as $alias => $value ) { | 
                                                        |
| 56 | +            if ( $value instanceof HasActions ) { | 
                                                        |
| 57 | + $loader->register_actions( $value );  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | +            if ( $value instanceof HasFilters ) { | 
                                                        |
| 61 | + $loader->register_filters( $value );  | 
                                                        |
| 62 | + }  | 
                                                        |
| 63 | + }  | 
                                                        |
| 64 | +  | 
                                                        |
| 65 | + add_action( 'plugins_loaded', array( $loader, 'run' ) );  | 
                                                        |
| 66 | + }  | 
                                                        |
| 67 | +  | 
                                                        |
| 68 | + /**  | 
                                                        |
| 69 | +     * {@inheritdoc} | 
                                                        |
| 70 | + *  | 
                                                        |
| 71 | + * @codeCoverageIgnore  | 
                                                        |
| 72 | + */  | 
                                                        |
| 73 | +    public function activate() { | 
                                                        |
| 74 | + // no-op  | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | + /**  | 
                                                        |
| 78 | +     * {@inheritdoc} | 
                                                        |
| 79 | + *  | 
                                                        |
| 80 | + * @codeCoverageIgnore  | 
                                                        |
| 81 | + */  | 
                                                        |
| 82 | +    public function deactivate() { | 
                                                        |
| 83 | + // no-op  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | +  | 
                                                        |
| 86 | + /**  | 
                                                        |
| 87 | +     * {@inheritDoc} | 
                                                        |
| 88 | + *  | 
                                                        |
| 89 | + * @return Application  | 
                                                        |
| 90 | + * @throws ApplicationNotBootedException  | 
                                                        |
| 91 | + */  | 
                                                        |
| 92 | +    public static function instance() { | 
                                                        |
| 93 | +        if ( static::$instance === null ) { | 
                                                        |
| 94 | + throw new ApplicationNotBootedException;  | 
                                                        |
| 95 | + }  | 
                                                        |
| 96 | +  | 
                                                        |
| 97 | + return static::$instance;  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | +  | 
                                                        |
| 100 | + /**  | 
                                                        |
| 101 | +     * {@inheritDoc} | 
                                                        |
| 102 | + */  | 
                                                        |
| 103 | +    public static function shutdown() { | 
                                                        |
| 104 | +        if ( static::$instance !== null ) { | 
                                                        |
| 105 | + static::$instance = null;  | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | + }  | 
                                                        |
| 108 | +  | 
                                                        |
| 109 | + /**  | 
                                                        |
| 110 | + * Sets the plugin's url, path, and basename.  | 
                                                        |
| 111 | + *  | 
                                                        |
| 112 | + * @param string $file  | 
                                                        |
| 113 | + */  | 
                                                        |
| 114 | +    private function register_constants( $file ) { | 
                                                        |
| 115 | + $this->share( 'url', plugin_dir_url( $file ) );  | 
                                                        |
| 116 | + $this->share( 'path', plugin_dir_path( $file ) );  | 
                                                        |
| 117 | + $this->share( 'basename', plugin_basename( $file ) );  | 
                                                        |
| 118 | +  | 
                                                        |
| 119 | + $plugin_data = get_plugin_data( $file, false, false );  | 
                                                        |
| 120 | + $this->share( 'version', isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : null );  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | +  | 
                                                        |
| 123 | + /**  | 
                                                        |
| 124 | + * Registers the built-in services with the Application container.  | 
                                                        |
| 125 | + */  | 
                                                        |
| 126 | +    private function register_core_services() { | 
                                                        |
| 127 | +        $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { | 
                                                        |
| 128 | + return new Loader( $app );  | 
                                                        |
| 129 | + } );  | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | +  | 
                                                        |
| 132 | + /**  | 
                                                        |
| 133 | + * Load's the plugin's translation files.  | 
                                                        |
| 134 | + */  | 
                                                        |
| 135 | +    private function load_i18n() { | 
                                                        |
| 136 | + load_plugin_textdomain(  | 
                                                        |
| 137 | + $this->fetch( 'basename' ),  | 
                                                        |
| 138 | + false,  | 
                                                        |
| 139 | + basename( $this->fetch( 'path' ) ) . '/languages/'  | 
                                                        |
| 140 | + );  | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | 142 | }  | 
                                                        
@@ -26,43 +26,43 @@ discard block  | 
                                                    ||
| 26 | 26 | *  | 
                                                        
| 27 | 27 | * @throws ApplicationAlreadyBootedException  | 
                                                        
| 28 | 28 | */  | 
                                                        
| 29 | -	public function __construct( $file, array $providers = array() ) { | 
                                                        |
| 30 | -		if ( static::$instance !== null ) { | 
                                                        |
| 29 | +	public function __construct($file, array $providers = array()) { | 
                                                        |
| 30 | +		if (static::$instance !== null) { | 
                                                        |
| 31 | 31 | throw new ApplicationAlreadyBootedException;  | 
                                                        
| 32 | 32 | }  | 
                                                        
| 33 | 33 | |
| 34 | 34 | static::$instance = $this;  | 
                                                        
| 35 | 35 | |
| 36 | - parent::__construct( $providers );  | 
                                                        |
| 37 | - $this->register_constants( $file );  | 
                                                        |
| 36 | + parent::__construct($providers);  | 
                                                        |
| 37 | + $this->register_constants($file);  | 
                                                        |
| 38 | 38 | $this->register_core_services();  | 
                                                        
| 39 | 39 | $this->load_i18n();  | 
                                                        
| 40 | 40 | |
| 41 | - register_activation_hook( $file, array( $this, 'activate' ) );  | 
                                                        |
| 42 | - register_deactivation_hook( $file, array( $this, 'deactivate' ) );  | 
                                                        |
| 41 | + register_activation_hook($file, array($this, 'activate'));  | 
                                                        |
| 42 | + register_deactivation_hook($file, array($this, 'deactivate'));  | 
                                                        |
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
| 45 | 45 | /**  | 
                                                        
| 46 | 46 |  	 * {@inheritDoc} | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | 48 |  	public function boot() { | 
                                                        
| 49 | - $loader = $this->fetch( 'loader' );  | 
                                                        |
| 49 | +		$loader = $this->fetch('loader'); | 
                                                        |
| 50 | 50 | |
| 51 | -		if ( ! $loader instanceof LoaderContract ) { | 
                                                        |
| 51 | +		if (!$loader instanceof LoaderContract) { | 
                                                        |
| 52 | 52 | throw new \UnexpectedValueException;  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | -		foreach ( $this as $alias => $value ) { | 
                                                        |
| 56 | -			if ( $value instanceof HasActions ) { | 
                                                        |
| 57 | - $loader->register_actions( $value );  | 
                                                        |
| 55 | +		foreach ($this as $alias => $value) { | 
                                                        |
| 56 | +			if ($value instanceof HasActions) { | 
                                                        |
| 57 | + $loader->register_actions($value);  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | -			if ( $value instanceof HasFilters ) { | 
                                                        |
| 61 | - $loader->register_filters( $value );  | 
                                                        |
| 60 | +			if ($value instanceof HasFilters) { | 
                                                        |
| 61 | + $loader->register_filters($value);  | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 | |
| 65 | - add_action( 'plugins_loaded', array( $loader, 'run' ) );  | 
                                                        |
| 65 | +		add_action('plugins_loaded', array($loader, 'run')); | 
                                                        |
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |
| 68 | 68 | /**  | 
                                                        
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | * @throws ApplicationNotBootedException  | 
                                                        
| 91 | 91 | */  | 
                                                        
| 92 | 92 |  	public static function instance() { | 
                                                        
| 93 | -		if ( static::$instance === null ) { | 
                                                        |
| 93 | +		if (static::$instance === null) { | 
                                                        |
| 94 | 94 | throw new ApplicationNotBootedException;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | |
@@ -101,7 +101,7 @@ discard block  | 
                                                    ||
| 101 | 101 |  	 * {@inheritDoc} | 
                                                        
| 102 | 102 | */  | 
                                                        
| 103 | 103 |  	public static function shutdown() { | 
                                                        
| 104 | -		if ( static::$instance !== null ) { | 
                                                        |
| 104 | +		if (static::$instance !== null) { | 
                                                        |
| 105 | 105 | static::$instance = null;  | 
                                                        
| 106 | 106 | }  | 
                                                        
| 107 | 107 | }  | 
                                                        
@@ -111,21 +111,21 @@ discard block  | 
                                                    ||
| 111 | 111 | *  | 
                                                        
| 112 | 112 | * @param string $file  | 
                                                        
| 113 | 113 | */  | 
                                                        
| 114 | -	private function register_constants( $file ) { | 
                                                        |
| 115 | - $this->share( 'url', plugin_dir_url( $file ) );  | 
                                                        |
| 116 | - $this->share( 'path', plugin_dir_path( $file ) );  | 
                                                        |
| 117 | - $this->share( 'basename', plugin_basename( $file ) );  | 
                                                        |
| 114 | +	private function register_constants($file) { | 
                                                        |
| 115 | +		$this->share('url', plugin_dir_url($file)); | 
                                                        |
| 116 | +		$this->share('path', plugin_dir_path($file)); | 
                                                        |
| 117 | +		$this->share('basename', plugin_basename($file)); | 
                                                        |
| 118 | 118 | |
| 119 | - $plugin_data = get_plugin_data( $file, false, false );  | 
                                                        |
| 120 | - $this->share( 'version', isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : null );  | 
                                                        |
| 119 | + $plugin_data = get_plugin_data($file, false, false);  | 
                                                        |
| 120 | +		$this->share('version', isset($plugin_data['Version']) ? $plugin_data['Version'] : null); | 
                                                        |
| 121 | 121 | }  | 
                                                        
| 122 | 122 | |
| 123 | 123 | /**  | 
                                                        
| 124 | 124 | * Registers the built-in services with the Application container.  | 
                                                        
| 125 | 125 | */  | 
                                                        
| 126 | 126 |  	private function register_core_services() { | 
                                                        
| 127 | -		$this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { | 
                                                        |
| 128 | - return new Loader( $app );  | 
                                                        |
| 127 | +		$this->share(array('loader' => 'Intraxia\Jaxion\Contract\Core\Loader'), function($app) { | 
                                                        |
| 128 | + return new Loader($app);  | 
                                                        |
| 129 | 129 | } );  | 
                                                        
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
@@ -134,9 +134,9 @@ discard block  | 
                                                    ||
| 134 | 134 | */  | 
                                                        
| 135 | 135 |  	private function load_i18n() { | 
                                                        
| 136 | 136 | load_plugin_textdomain(  | 
                                                        
| 137 | - $this->fetch( 'basename' ),  | 
                                                        |
| 137 | +			$this->fetch('basename'), | 
                                                        |
| 138 | 138 | false,  | 
                                                        
| 139 | - basename( $this->fetch( 'path' ) ) . '/languages/'  | 
                                                        |
| 139 | +			basename($this->fetch('path')) . '/languages/' | 
                                                        |
| 140 | 140 | );  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | 142 | }  | 
                                                        
@@ -2,7 +2,6 @@  | 
                                                    ||
| 2 | 2 | namespace Intraxia\Jaxion\Http;  | 
                                                        
| 3 | 3 | |
| 4 | 4 | use Intraxia\Jaxion\Contract\Http\Guard as GuardContract;  | 
                                                        
| 5 | -use Intraxia\Jaxion\Utility\Str;  | 
                                                        |
| 6 | 5 | use WP_Error;  | 
                                                        
| 7 | 6 | |
| 8 | 7 | /**  | 
                                                        
@@ -15,77 +15,77 @@  | 
                                                    ||
| 15 | 15 | * @subpackage Http  | 
                                                        
| 16 | 16 | */  | 
                                                        
| 17 | 17 |  class Guard implements GuardContract { | 
                                                        
| 18 | - /**  | 
                                                        |
| 19 | - * Default options.  | 
                                                        |
| 20 | - *  | 
                                                        |
| 21 | - * @var array  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - protected $defaults = array(  | 
                                                        |
| 24 | - 'rule' => 'public',  | 
                                                        |
| 25 | - 'callback' => false,  | 
                                                        |
| 26 | - );  | 
                                                        |
| 18 | + /**  | 
                                                        |
| 19 | + * Default options.  | 
                                                        |
| 20 | + *  | 
                                                        |
| 21 | + * @var array  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + protected $defaults = array(  | 
                                                        |
| 24 | + 'rule' => 'public',  | 
                                                        |
| 25 | + 'callback' => false,  | 
                                                        |
| 26 | + );  | 
                                                        |
| 27 | 27 | |
| 28 | - /**  | 
                                                        |
| 29 | - * Guard options.  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @var array  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - protected $options;  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * Guard options.  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @var array  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + protected $options;  | 
                                                        |
| 34 | 34 | |
| 35 | - /**  | 
                                                        |
| 36 | - * Instantiate a new Guard with provided options.  | 
                                                        |
| 37 | - *  | 
                                                        |
| 38 | - * @param array $options  | 
                                                        |
| 39 | - */  | 
                                                        |
| 40 | -	public function __construct( array $options = array() ) { | 
                                                        |
| 41 | - $this->options = $this->set_defaults( $options );  | 
                                                        |
| 42 | - }  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * Instantiate a new Guard with provided options.  | 
                                                        |
| 37 | + *  | 
                                                        |
| 38 | + * @param array $options  | 
                                                        |
| 39 | + */  | 
                                                        |
| 40 | +    public function __construct( array $options = array() ) { | 
                                                        |
| 41 | + $this->options = $this->set_defaults( $options );  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | 43 | |
| 44 | - /**  | 
                                                        |
| 45 | - * Validates whether the current user is authorized.  | 
                                                        |
| 46 | - *  | 
                                                        |
| 47 | - * @return true|WP_Error  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | -	public function authorized() { | 
                                                        |
| 50 | - // if the rule is public, always authorized  | 
                                                        |
| 51 | -		if ( 'public' === $this->options['rule'] ) { | 
                                                        |
| 52 | - return true;  | 
                                                        |
| 53 | - }  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * Validates whether the current user is authorized.  | 
                                                        |
| 46 | + *  | 
                                                        |
| 47 | + * @return true|WP_Error  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | +    public function authorized() { | 
                                                        |
| 50 | + // if the rule is public, always authorized  | 
                                                        |
| 51 | +        if ( 'public' === $this->options['rule'] ) { | 
                                                        |
| 52 | + return true;  | 
                                                        |
| 53 | + }  | 
                                                        |
| 54 | 54 | |
| 55 | - // enable passing in callback  | 
                                                        |
| 56 | -		if ( 'callback' === $this->options['rule'] && is_callable( $this->options['callback'] ) ) { | 
                                                        |
| 57 | - return call_user_func( $this->options['callback'] );  | 
                                                        |
| 58 | - }  | 
                                                        |
| 55 | + // enable passing in callback  | 
                                                        |
| 56 | +        if ( 'callback' === $this->options['rule'] && is_callable( $this->options['callback'] ) ) { | 
                                                        |
| 57 | + return call_user_func( $this->options['callback'] );  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | 59 | |
| 60 | - // map rule to method  | 
                                                        |
| 61 | -		if ( method_exists( $this, $method = $this->options['rule'] ) ) { | 
                                                        |
| 62 | -			return $this->{$method}(); | 
                                                        |
| 63 | - }  | 
                                                        |
| 60 | + // map rule to method  | 
                                                        |
| 61 | +        if ( method_exists( $this, $method = $this->options['rule'] ) ) { | 
                                                        |
| 62 | +            return $this->{$method}(); | 
                                                        |
| 63 | + }  | 
                                                        |
| 64 | 64 | |
| 65 | - // disable in rule is misconfigused  | 
                                                        |
| 66 | - // @todo set up internal translations  | 
                                                        |
| 67 | - // @todo also, this error message kinda sucks  | 
                                                        |
| 68 | - return new WP_Error( '500', __( 'Guard failure', 'jaxion' ) );  | 
                                                        |
| 69 | - }  | 
                                                        |
| 65 | + // disable in rule is misconfigused  | 
                                                        |
| 66 | + // @todo set up internal translations  | 
                                                        |
| 67 | + // @todo also, this error message kinda sucks  | 
                                                        |
| 68 | + return new WP_Error( '500', __( 'Guard failure', 'jaxion' ) );  | 
                                                        |
| 69 | + }  | 
                                                        |
| 70 | 70 | |
| 71 | - /**  | 
                                                        |
| 72 | - * Checks whether the current user can edit other's posts.  | 
                                                        |
| 73 | - *  | 
                                                        |
| 74 | - * @return bool  | 
                                                        |
| 75 | - */  | 
                                                        |
| 76 | -	protected function can_edit_others_posts() { | 
                                                        |
| 77 | - return current_user_can( 'edit_others_posts' ) ?: new WP_Error( '401', __( 'Unauthorized user', 'jaxion' ) );  | 
                                                        |
| 78 | - }  | 
                                                        |
| 71 | + /**  | 
                                                        |
| 72 | + * Checks whether the current user can edit other's posts.  | 
                                                        |
| 73 | + *  | 
                                                        |
| 74 | + * @return bool  | 
                                                        |
| 75 | + */  | 
                                                        |
| 76 | +    protected function can_edit_others_posts() { | 
                                                        |
| 77 | + return current_user_can( 'edit_others_posts' ) ?: new WP_Error( '401', __( 'Unauthorized user', 'jaxion' ) );  | 
                                                        |
| 78 | + }  | 
                                                        |
| 79 | 79 | |
| 80 | - /**  | 
                                                        |
| 81 | - * Sets the default params for the Guard options.  | 
                                                        |
| 82 | - *  | 
                                                        |
| 83 | - * @param array $options  | 
                                                        |
| 84 | - *  | 
                                                        |
| 85 | - * @return array  | 
                                                        |
| 86 | - */  | 
                                                        |
| 87 | -	protected function set_defaults( $options ) { | 
                                                        |
| 88 | - // these are the valid options  | 
                                                        |
| 89 | - return wp_parse_args( $options, $this->defaults );  | 
                                                        |
| 90 | - }  | 
                                                        |
| 80 | + /**  | 
                                                        |
| 81 | + * Sets the default params for the Guard options.  | 
                                                        |
| 82 | + *  | 
                                                        |
| 83 | + * @param array $options  | 
                                                        |
| 84 | + *  | 
                                                        |
| 85 | + * @return array  | 
                                                        |
| 86 | + */  | 
                                                        |
| 87 | +    protected function set_defaults( $options ) { | 
                                                        |
| 88 | + // these are the valid options  | 
                                                        |
| 89 | + return wp_parse_args( $options, $this->defaults );  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | 91 | }  | 
                                                        
@@ -37,8 +37,8 @@ discard block  | 
                                                    ||
| 37 | 37 | *  | 
                                                        
| 38 | 38 | * @param array $options  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | -	public function __construct( array $options = array() ) { | 
                                                        |
| 41 | - $this->options = $this->set_defaults( $options );  | 
                                                        |
| 40 | +	public function __construct(array $options = array()) { | 
                                                        |
| 41 | + $this->options = $this->set_defaults($options);  | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | 44 | /**  | 
                                                        
@@ -48,24 +48,24 @@ discard block  | 
                                                    ||
| 48 | 48 | */  | 
                                                        
| 49 | 49 |  	public function authorized() { | 
                                                        
| 50 | 50 | // if the rule is public, always authorized  | 
                                                        
| 51 | -		if ( 'public' === $this->options['rule'] ) { | 
                                                        |
| 51 | +		if ('public' === $this->options['rule']) { | 
                                                        |
| 52 | 52 | return true;  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | 55 | // enable passing in callback  | 
                                                        
| 56 | -		if ( 'callback' === $this->options['rule'] && is_callable( $this->options['callback'] ) ) { | 
                                                        |
| 57 | - return call_user_func( $this->options['callback'] );  | 
                                                        |
| 56 | +		if ('callback' === $this->options['rule'] && is_callable($this->options['callback'])) { | 
                                                        |
| 57 | + return call_user_func($this->options['callback']);  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | 60 | // map rule to method  | 
                                                        
| 61 | -		if ( method_exists( $this, $method = $this->options['rule'] ) ) { | 
                                                        |
| 61 | +		if (method_exists($this, $method = $this->options['rule'])) { | 
                                                        |
| 62 | 62 |  			return $this->{$method}(); | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 | |
| 65 | 65 | // disable in rule is misconfigused  | 
                                                        
| 66 | 66 | // @todo set up internal translations  | 
                                                        
| 67 | 67 | // @todo also, this error message kinda sucks  | 
                                                        
| 68 | - return new WP_Error( '500', __( 'Guard failure', 'jaxion' ) );  | 
                                                        |
| 68 | +		return new WP_Error('500', __('Guard failure', 'jaxion')); | 
                                                        |
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | 71 | /**  | 
                                                        
@@ -74,7 +74,7 @@ discard block  | 
                                                    ||
| 74 | 74 | * @return bool  | 
                                                        
| 75 | 75 | */  | 
                                                        
| 76 | 76 |  	protected function can_edit_others_posts() { | 
                                                        
| 77 | - return current_user_can( 'edit_others_posts' ) ?: new WP_Error( '401', __( 'Unauthorized user', 'jaxion' ) );  | 
                                                        |
| 77 | +		return current_user_can('edit_others_posts') ?: new WP_Error('401', __('Unauthorized user', 'jaxion')); | 
                                                        |
| 78 | 78 | }  | 
                                                        
| 79 | 79 | |
| 80 | 80 | /**  | 
                                                        
@@ -84,8 +84,8 @@ discard block  | 
                                                    ||
| 84 | 84 | *  | 
                                                        
| 85 | 85 | * @return array  | 
                                                        
| 86 | 86 | */  | 
                                                        
| 87 | -	protected function set_defaults( $options ) { | 
                                                        |
| 87 | +	protected function set_defaults($options) { | 
                                                        |
| 88 | 88 | // these are the valid options  | 
                                                        
| 89 | - return wp_parse_args( $options, $this->defaults );  | 
                                                        |
| 89 | + return wp_parse_args($options, $this->defaults);  | 
                                                        |
| 90 | 90 | }  | 
                                                        
| 91 | 91 | }  | 
                                                        
@@ -1,7 +1,6 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | namespace Intraxia\Jaxion\Model;  | 
                                                        
| 3 | 3 | |
| 4 | -use Intraxia\Jaxion\Utility\Str;  | 
                                                        |
| 5 | 4 | use stdClass;  | 
                                                        
| 6 | 5 | use WP_Post;  | 
                                                        
| 7 | 6 | |
@@ -17,258 +17,258 @@  | 
                                                    ||
| 17 | 17 | * @since 0.1.0  | 
                                                        
| 18 | 18 | */  | 
                                                        
| 19 | 19 |  abstract class Base { | 
                                                        
| 20 | - /**  | 
                                                        |
| 21 | - * Model attributes array.  | 
                                                        |
| 22 | - *  | 
                                                        |
| 23 | - * @var array  | 
                                                        |
| 24 | - */  | 
                                                        |
| 25 | - private $attributes = array(  | 
                                                        |
| 26 | - 'table' => array(),  | 
                                                        |
| 27 | - 'post' => null,  | 
                                                        |
| 28 | - );  | 
                                                        |
| 29 | -  | 
                                                        |
| 30 | - /**  | 
                                                        |
| 31 | - * Which custom table does this model uses.  | 
                                                        |
| 32 | - *  | 
                                                        |
| 33 | - * If false, model wil fall back to postmeta.  | 
                                                        |
| 34 | - *  | 
                                                        |
| 35 | - * @var bool|string  | 
                                                        |
| 36 | - */  | 
                                                        |
| 37 | - protected $table = false;  | 
                                                        |
| 38 | -  | 
                                                        |
| 39 | - /**  | 
                                                        |
| 40 | - * Whether to use WP_Post mappings.  | 
                                                        |
| 41 | - *  | 
                                                        |
| 42 | - * @var bool  | 
                                                        |
| 43 | - */  | 
                                                        |
| 44 | - protected $post = true;  | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - /**  | 
                                                        |
| 47 | - * Custom post type.  | 
                                                        |
| 48 | - *  | 
                                                        |
| 49 | - * @var bool|string  | 
                                                        |
| 50 | - */  | 
                                                        |
| 51 | - protected $type = false;  | 
                                                        |
| 52 | -  | 
                                                        |
| 53 | - /**  | 
                                                        |
| 54 | - * Properties which are allowed to be set on the model.  | 
                                                        |
| 55 | - *  | 
                                                        |
| 56 | - * If this array is empty, any attributes can be set on the model.  | 
                                                        |
| 57 | - *  | 
                                                        |
| 58 | - * @var string[]  | 
                                                        |
| 59 | - */  | 
                                                        |
| 60 | - protected $fillable = array();  | 
                                                        |
| 61 | -  | 
                                                        |
| 62 | - /**  | 
                                                        |
| 63 | - * Constructs a new model with provided attributes.  | 
                                                        |
| 64 | - *  | 
                                                        |
| 65 | - * If 'post' is passed as one of the attributes  | 
                                                        |
| 66 | - *  | 
                                                        |
| 67 | - * @param array <string, mixed> $attributes  | 
                                                        |
| 68 | - */  | 
                                                        |
| 69 | -	public function __construct( array $attributes = array() ) { | 
                                                        |
| 70 | -		foreach ( $attributes as $name => $value ) { | 
                                                        |
| 71 | - $this->set_attribute( $name, $value );  | 
                                                        |
| 72 | - }  | 
                                                        |
| 73 | -  | 
                                                        |
| 74 | -		if ( $this->post && ! isset( $this->attributes['post'] ) ) { | 
                                                        |
| 75 | - $this->create_default_post();  | 
                                                        |
| 76 | - }  | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | - /**  | 
                                                        |
| 80 | - * Get the model's attributes.  | 
                                                        |
| 81 | - *  | 
                                                        |
| 82 | - * Returns the array of for the model that will either need to be  | 
                                                        |
| 83 | - * saved in postmeta or a separate table.  | 
                                                        |
| 84 | - *  | 
                                                        |
| 85 | - * @return array  | 
                                                        |
| 86 | - */  | 
                                                        |
| 87 | -	public function get_attributes() { | 
                                                        |
| 88 | - return $this->attributes['table'];  | 
                                                        |
| 89 | - }  | 
                                                        |
| 90 | -  | 
                                                        |
| 91 | - /**  | 
                                                        |
| 92 | - * Get the model's underlying post.  | 
                                                        |
| 93 | - *  | 
                                                        |
| 94 | - * Returns the underlying WP_Post object for the model, representing  | 
                                                        |
| 95 | - * the data that will be save in the wp_posts table.  | 
                                                        |
| 96 | - *  | 
                                                        |
| 97 | - * @return false|WP_Post  | 
                                                        |
| 98 | - */  | 
                                                        |
| 99 | -	public function get_underlying_post() { | 
                                                        |
| 100 | -		if ( isset( $this->attributes['post'] ) ) { | 
                                                        |
| 101 | - return $this->attributes['post'];  | 
                                                        |
| 102 | - }  | 
                                                        |
| 103 | -  | 
                                                        |
| 104 | - return false;  | 
                                                        |
| 105 | - }  | 
                                                        |
| 106 | -  | 
                                                        |
| 107 | - /**  | 
                                                        |
| 108 | - * Magic __set method.  | 
                                                        |
| 109 | - *  | 
                                                        |
| 110 | - * Passes the name and value to set_attribute, which is where the magic happens.  | 
                                                        |
| 111 | - *  | 
                                                        |
| 112 | - * @param string $name  | 
                                                        |
| 113 | - * @param mixed $value  | 
                                                        |
| 114 | - */  | 
                                                        |
| 115 | -	public function __set( $name, $value ) { | 
                                                        |
| 116 | - $this->set_attribute( $name, $value );  | 
                                                        |
| 117 | - }  | 
                                                        |
| 118 | -  | 
                                                        |
| 119 | - /**  | 
                                                        |
| 120 | - * Sets the model attributes.  | 
                                                        |
| 121 | - *  | 
                                                        |
| 122 | - * Checks whether the model attribute can be set, check if it  | 
                                                        |
| 123 | - * maps to the WP_Post property, otherwise, assigns it to the  | 
                                                        |
| 124 | - * table attribute array.  | 
                                                        |
| 125 | - *  | 
                                                        |
| 126 | - * @param string $name  | 
                                                        |
| 127 | - * @param mixed $value  | 
                                                        |
| 128 | - */  | 
                                                        |
| 129 | -	private function set_attribute( $name, $value ) { | 
                                                        |
| 130 | -		if ( 'post' === $name ) { | 
                                                        |
| 131 | - $this->override_post( $value );  | 
                                                        |
| 132 | -  | 
                                                        |
| 133 | - return;  | 
                                                        |
| 134 | - }  | 
                                                        |
| 135 | -  | 
                                                        |
| 136 | -		if ( ! $this->is_fillable( $name ) ) { | 
                                                        |
| 137 | - return;  | 
                                                        |
| 138 | - }  | 
                                                        |
| 139 | -  | 
                                                        |
| 140 | -		if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 141 | -			$this->attributes['post']->{$this->{$method}()} = $value; | 
                                                        |
| 142 | -  | 
                                                        |
| 143 | - return;  | 
                                                        |
| 144 | - }  | 
                                                        |
| 145 | -  | 
                                                        |
| 146 | - $this->attributes['table'][ $name ] = $value;  | 
                                                        |
| 147 | - }  | 
                                                        |
| 148 | -  | 
                                                        |
| 149 | - /**  | 
                                                        |
| 150 | - * Checks if a given attribute is mass-fillable.  | 
                                                        |
| 151 | - *  | 
                                                        |
| 152 | - * Returns true if the attribute can be filled, false if it can't.  | 
                                                        |
| 153 | - *  | 
                                                        |
| 154 | - * @param string $name  | 
                                                        |
| 155 | - *  | 
                                                        |
| 156 | - * @return bool  | 
                                                        |
| 157 | - */  | 
                                                        |
| 158 | -	private function is_fillable( $name ) { | 
                                                        |
| 159 | - // `type` is not fillable at all.  | 
                                                        |
| 160 | -		if ( 'type' === $name ) { | 
                                                        |
| 161 | - return false;  | 
                                                        |
| 162 | - }  | 
                                                        |
| 163 | -  | 
                                                        |
| 164 | - // If the `$fillable` array hasn't been defined, pass everything.  | 
                                                        |
| 165 | -		if ( ! $this->fillable ) { | 
                                                        |
| 166 | - return true;  | 
                                                        |
| 167 | - }  | 
                                                        |
| 168 | -  | 
                                                        |
| 169 | - return in_array( $name, $this->fillable );  | 
                                                        |
| 170 | - }  | 
                                                        |
| 171 | -  | 
                                                        |
| 172 | - /**  | 
                                                        |
| 173 | - * Overrides the current WP_Post with a provided one.  | 
                                                        |
| 174 | - *  | 
                                                        |
| 175 | - * Resets the post's default values and stores it in the attributes.  | 
                                                        |
| 176 | - *  | 
                                                        |
| 177 | - * @param WP_Post $value  | 
                                                        |
| 178 | - */  | 
                                                        |
| 179 | -	private function override_post( WP_Post $value ) { | 
                                                        |
| 180 | - $this->attributes['post'] = $this->enforce_post_defaults( $value );  | 
                                                        |
| 181 | - }  | 
                                                        |
| 182 | -  | 
                                                        |
| 183 | - /**  | 
                                                        |
| 184 | - * Create and set with a new blank post.  | 
                                                        |
| 185 | - *  | 
                                                        |
| 186 | - * Creates a new WP_Post object, assigns it the default attributes,  | 
                                                        |
| 187 | - * and stores it in the attributes.  | 
                                                        |
| 188 | - */  | 
                                                        |
| 189 | -	private function create_default_post() { | 
                                                        |
| 190 | - $this->attributes['post'] = $this->enforce_post_defaults( new WP_Post( new stdClass ) );  | 
                                                        |
| 191 | - }  | 
                                                        |
| 192 | -  | 
                                                        |
| 193 | - /**  | 
                                                        |
| 194 | - * Enforces values on the post that can't change.  | 
                                                        |
| 195 | - *  | 
                                                        |
| 196 | - * Primarily, this is used to make sure the post_type always maps  | 
                                                        |
| 197 | - * to the model's "$type" property, but this can all be overridden  | 
                                                        |
| 198 | - * by the developer to enforce other values in the model.  | 
                                                        |
| 199 | - *  | 
                                                        |
| 200 | - * @param WP_Post $post  | 
                                                        |
| 201 | - *  | 
                                                        |
| 202 | - * @return WP_Post  | 
                                                        |
| 203 | - */  | 
                                                        |
| 204 | -	protected function enforce_post_defaults( WP_Post $post ) { | 
                                                        |
| 205 | -		if ( is_string( $this->type ) ) { | 
                                                        |
| 206 | - $post->post_type = $this->type;  | 
                                                        |
| 207 | - }  | 
                                                        |
| 208 | -  | 
                                                        |
| 209 | - return $post;  | 
                                                        |
| 210 | - }  | 
                                                        |
| 211 | -  | 
                                                        |
| 212 | - /**  | 
                                                        |
| 213 | - * Magic __get method.  | 
                                                        |
| 214 | - *  | 
                                                        |
| 215 | - * Passes the name and value to get_attribute, which is where the magic happens.  | 
                                                        |
| 216 | - *  | 
                                                        |
| 217 | - * @param string $name  | 
                                                        |
| 218 | - *  | 
                                                        |
| 219 | - * @return mixed  | 
                                                        |
| 220 | - */  | 
                                                        |
| 221 | -	public function __get( $name ) { | 
                                                        |
| 222 | - return $this->get_attribute( $name );  | 
                                                        |
| 223 | - }  | 
                                                        |
| 224 | -  | 
                                                        |
| 225 | - /**  | 
                                                        |
| 226 | - * Retrieves the model attribute.  | 
                                                        |
| 227 | - *  | 
                                                        |
| 228 | - * If the attribute maps to the WP_Post, retrieves it from there.  | 
                                                        |
| 229 | - * Otherwise, checks if it's in the attributes array  | 
                                                        |
| 230 | - *  | 
                                                        |
| 231 | - * @param string $name  | 
                                                        |
| 232 | - *  | 
                                                        |
| 233 | - * @return mixed  | 
                                                        |
| 234 | - *  | 
                                                        |
| 235 | - * @throws PropertyDoesNotExistException If property isn't found.  | 
                                                        |
| 236 | - */  | 
                                                        |
| 237 | -	protected function get_attribute( $name ) { | 
                                                        |
| 238 | -		if ( 'type' === $name ) { | 
                                                        |
| 239 | - return $this->type;  | 
                                                        |
| 240 | - }  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | -		if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 243 | -			$value = $this->attributes['post']->{$this->{$method}()}; | 
                                                        |
| 244 | -		} else { | 
                                                        |
| 245 | -			if ( ! isset( $this->attributes['table'][ $name ] ) ) { | 
                                                        |
| 246 | - throw new PropertyDoesNotExistException;  | 
                                                        |
| 247 | - }  | 
                                                        |
| 248 | -  | 
                                                        |
| 249 | - $value = $this->attributes['table'][ $name ];  | 
                                                        |
| 250 | - }  | 
                                                        |
| 251 | -  | 
                                                        |
| 252 | - return $value;  | 
                                                        |
| 253 | -  | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | -  | 
                                                        |
| 256 | - /**  | 
                                                        |
| 257 | - * Checks whether the attribute has a map method.  | 
                                                        |
| 258 | - *  | 
                                                        |
| 259 | - * This is used to determine whether the attribute maps to a  | 
                                                        |
| 260 | - * property on the underlying WP_Post object. Returns the  | 
                                                        |
| 261 | - * method if one exists, returns false if it doesn't.  | 
                                                        |
| 262 | - *  | 
                                                        |
| 263 | - * @param string $name  | 
                                                        |
| 264 | - *  | 
                                                        |
| 265 | - * @return false|string  | 
                                                        |
| 266 | - */  | 
                                                        |
| 267 | -	protected function has_map_method( $name ) { | 
                                                        |
| 268 | -		if ( method_exists( $this, $method = "map_{$name}" ) ) { | 
                                                        |
| 269 | - return $method;  | 
                                                        |
| 270 | - }  | 
                                                        |
| 271 | -  | 
                                                        |
| 272 | - return false;  | 
                                                        |
| 273 | - }  | 
                                                        |
| 20 | + /**  | 
                                                        |
| 21 | + * Model attributes array.  | 
                                                        |
| 22 | + *  | 
                                                        |
| 23 | + * @var array  | 
                                                        |
| 24 | + */  | 
                                                        |
| 25 | + private $attributes = array(  | 
                                                        |
| 26 | + 'table' => array(),  | 
                                                        |
| 27 | + 'post' => null,  | 
                                                        |
| 28 | + );  | 
                                                        |
| 29 | +  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * Which custom table does this model uses.  | 
                                                        |
| 32 | + *  | 
                                                        |
| 33 | + * If false, model wil fall back to postmeta.  | 
                                                        |
| 34 | + *  | 
                                                        |
| 35 | + * @var bool|string  | 
                                                        |
| 36 | + */  | 
                                                        |
| 37 | + protected $table = false;  | 
                                                        |
| 38 | +  | 
                                                        |
| 39 | + /**  | 
                                                        |
| 40 | + * Whether to use WP_Post mappings.  | 
                                                        |
| 41 | + *  | 
                                                        |
| 42 | + * @var bool  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | + protected $post = true;  | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + /**  | 
                                                        |
| 47 | + * Custom post type.  | 
                                                        |
| 48 | + *  | 
                                                        |
| 49 | + * @var bool|string  | 
                                                        |
| 50 | + */  | 
                                                        |
| 51 | + protected $type = false;  | 
                                                        |
| 52 | +  | 
                                                        |
| 53 | + /**  | 
                                                        |
| 54 | + * Properties which are allowed to be set on the model.  | 
                                                        |
| 55 | + *  | 
                                                        |
| 56 | + * If this array is empty, any attributes can be set on the model.  | 
                                                        |
| 57 | + *  | 
                                                        |
| 58 | + * @var string[]  | 
                                                        |
| 59 | + */  | 
                                                        |
| 60 | + protected $fillable = array();  | 
                                                        |
| 61 | +  | 
                                                        |
| 62 | + /**  | 
                                                        |
| 63 | + * Constructs a new model with provided attributes.  | 
                                                        |
| 64 | + *  | 
                                                        |
| 65 | + * If 'post' is passed as one of the attributes  | 
                                                        |
| 66 | + *  | 
                                                        |
| 67 | + * @param array <string, mixed> $attributes  | 
                                                        |
| 68 | + */  | 
                                                        |
| 69 | +    public function __construct( array $attributes = array() ) { | 
                                                        |
| 70 | +        foreach ( $attributes as $name => $value ) { | 
                                                        |
| 71 | + $this->set_attribute( $name, $value );  | 
                                                        |
| 72 | + }  | 
                                                        |
| 73 | +  | 
                                                        |
| 74 | +        if ( $this->post && ! isset( $this->attributes['post'] ) ) { | 
                                                        |
| 75 | + $this->create_default_post();  | 
                                                        |
| 76 | + }  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | + /**  | 
                                                        |
| 80 | + * Get the model's attributes.  | 
                                                        |
| 81 | + *  | 
                                                        |
| 82 | + * Returns the array of for the model that will either need to be  | 
                                                        |
| 83 | + * saved in postmeta or a separate table.  | 
                                                        |
| 84 | + *  | 
                                                        |
| 85 | + * @return array  | 
                                                        |
| 86 | + */  | 
                                                        |
| 87 | +    public function get_attributes() { | 
                                                        |
| 88 | + return $this->attributes['table'];  | 
                                                        |
| 89 | + }  | 
                                                        |
| 90 | +  | 
                                                        |
| 91 | + /**  | 
                                                        |
| 92 | + * Get the model's underlying post.  | 
                                                        |
| 93 | + *  | 
                                                        |
| 94 | + * Returns the underlying WP_Post object for the model, representing  | 
                                                        |
| 95 | + * the data that will be save in the wp_posts table.  | 
                                                        |
| 96 | + *  | 
                                                        |
| 97 | + * @return false|WP_Post  | 
                                                        |
| 98 | + */  | 
                                                        |
| 99 | +    public function get_underlying_post() { | 
                                                        |
| 100 | +        if ( isset( $this->attributes['post'] ) ) { | 
                                                        |
| 101 | + return $this->attributes['post'];  | 
                                                        |
| 102 | + }  | 
                                                        |
| 103 | +  | 
                                                        |
| 104 | + return false;  | 
                                                        |
| 105 | + }  | 
                                                        |
| 106 | +  | 
                                                        |
| 107 | + /**  | 
                                                        |
| 108 | + * Magic __set method.  | 
                                                        |
| 109 | + *  | 
                                                        |
| 110 | + * Passes the name and value to set_attribute, which is where the magic happens.  | 
                                                        |
| 111 | + *  | 
                                                        |
| 112 | + * @param string $name  | 
                                                        |
| 113 | + * @param mixed $value  | 
                                                        |
| 114 | + */  | 
                                                        |
| 115 | +    public function __set( $name, $value ) { | 
                                                        |
| 116 | + $this->set_attribute( $name, $value );  | 
                                                        |
| 117 | + }  | 
                                                        |
| 118 | +  | 
                                                        |
| 119 | + /**  | 
                                                        |
| 120 | + * Sets the model attributes.  | 
                                                        |
| 121 | + *  | 
                                                        |
| 122 | + * Checks whether the model attribute can be set, check if it  | 
                                                        |
| 123 | + * maps to the WP_Post property, otherwise, assigns it to the  | 
                                                        |
| 124 | + * table attribute array.  | 
                                                        |
| 125 | + *  | 
                                                        |
| 126 | + * @param string $name  | 
                                                        |
| 127 | + * @param mixed $value  | 
                                                        |
| 128 | + */  | 
                                                        |
| 129 | +    private function set_attribute( $name, $value ) { | 
                                                        |
| 130 | +        if ( 'post' === $name ) { | 
                                                        |
| 131 | + $this->override_post( $value );  | 
                                                        |
| 132 | +  | 
                                                        |
| 133 | + return;  | 
                                                        |
| 134 | + }  | 
                                                        |
| 135 | +  | 
                                                        |
| 136 | +        if ( ! $this->is_fillable( $name ) ) { | 
                                                        |
| 137 | + return;  | 
                                                        |
| 138 | + }  | 
                                                        |
| 139 | +  | 
                                                        |
| 140 | +        if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 141 | +            $this->attributes['post']->{$this->{$method}()} = $value; | 
                                                        |
| 142 | +  | 
                                                        |
| 143 | + return;  | 
                                                        |
| 144 | + }  | 
                                                        |
| 145 | +  | 
                                                        |
| 146 | + $this->attributes['table'][ $name ] = $value;  | 
                                                        |
| 147 | + }  | 
                                                        |
| 148 | +  | 
                                                        |
| 149 | + /**  | 
                                                        |
| 150 | + * Checks if a given attribute is mass-fillable.  | 
                                                        |
| 151 | + *  | 
                                                        |
| 152 | + * Returns true if the attribute can be filled, false if it can't.  | 
                                                        |
| 153 | + *  | 
                                                        |
| 154 | + * @param string $name  | 
                                                        |
| 155 | + *  | 
                                                        |
| 156 | + * @return bool  | 
                                                        |
| 157 | + */  | 
                                                        |
| 158 | +    private function is_fillable( $name ) { | 
                                                        |
| 159 | + // `type` is not fillable at all.  | 
                                                        |
| 160 | +        if ( 'type' === $name ) { | 
                                                        |
| 161 | + return false;  | 
                                                        |
| 162 | + }  | 
                                                        |
| 163 | +  | 
                                                        |
| 164 | + // If the `$fillable` array hasn't been defined, pass everything.  | 
                                                        |
| 165 | +        if ( ! $this->fillable ) { | 
                                                        |
| 166 | + return true;  | 
                                                        |
| 167 | + }  | 
                                                        |
| 168 | +  | 
                                                        |
| 169 | + return in_array( $name, $this->fillable );  | 
                                                        |
| 170 | + }  | 
                                                        |
| 171 | +  | 
                                                        |
| 172 | + /**  | 
                                                        |
| 173 | + * Overrides the current WP_Post with a provided one.  | 
                                                        |
| 174 | + *  | 
                                                        |
| 175 | + * Resets the post's default values and stores it in the attributes.  | 
                                                        |
| 176 | + *  | 
                                                        |
| 177 | + * @param WP_Post $value  | 
                                                        |
| 178 | + */  | 
                                                        |
| 179 | +    private function override_post( WP_Post $value ) { | 
                                                        |
| 180 | + $this->attributes['post'] = $this->enforce_post_defaults( $value );  | 
                                                        |
| 181 | + }  | 
                                                        |
| 182 | +  | 
                                                        |
| 183 | + /**  | 
                                                        |
| 184 | + * Create and set with a new blank post.  | 
                                                        |
| 185 | + *  | 
                                                        |
| 186 | + * Creates a new WP_Post object, assigns it the default attributes,  | 
                                                        |
| 187 | + * and stores it in the attributes.  | 
                                                        |
| 188 | + */  | 
                                                        |
| 189 | +    private function create_default_post() { | 
                                                        |
| 190 | + $this->attributes['post'] = $this->enforce_post_defaults( new WP_Post( new stdClass ) );  | 
                                                        |
| 191 | + }  | 
                                                        |
| 192 | +  | 
                                                        |
| 193 | + /**  | 
                                                        |
| 194 | + * Enforces values on the post that can't change.  | 
                                                        |
| 195 | + *  | 
                                                        |
| 196 | + * Primarily, this is used to make sure the post_type always maps  | 
                                                        |
| 197 | + * to the model's "$type" property, but this can all be overridden  | 
                                                        |
| 198 | + * by the developer to enforce other values in the model.  | 
                                                        |
| 199 | + *  | 
                                                        |
| 200 | + * @param WP_Post $post  | 
                                                        |
| 201 | + *  | 
                                                        |
| 202 | + * @return WP_Post  | 
                                                        |
| 203 | + */  | 
                                                        |
| 204 | +    protected function enforce_post_defaults( WP_Post $post ) { | 
                                                        |
| 205 | +        if ( is_string( $this->type ) ) { | 
                                                        |
| 206 | + $post->post_type = $this->type;  | 
                                                        |
| 207 | + }  | 
                                                        |
| 208 | +  | 
                                                        |
| 209 | + return $post;  | 
                                                        |
| 210 | + }  | 
                                                        |
| 211 | +  | 
                                                        |
| 212 | + /**  | 
                                                        |
| 213 | + * Magic __get method.  | 
                                                        |
| 214 | + *  | 
                                                        |
| 215 | + * Passes the name and value to get_attribute, which is where the magic happens.  | 
                                                        |
| 216 | + *  | 
                                                        |
| 217 | + * @param string $name  | 
                                                        |
| 218 | + *  | 
                                                        |
| 219 | + * @return mixed  | 
                                                        |
| 220 | + */  | 
                                                        |
| 221 | +    public function __get( $name ) { | 
                                                        |
| 222 | + return $this->get_attribute( $name );  | 
                                                        |
| 223 | + }  | 
                                                        |
| 224 | +  | 
                                                        |
| 225 | + /**  | 
                                                        |
| 226 | + * Retrieves the model attribute.  | 
                                                        |
| 227 | + *  | 
                                                        |
| 228 | + * If the attribute maps to the WP_Post, retrieves it from there.  | 
                                                        |
| 229 | + * Otherwise, checks if it's in the attributes array  | 
                                                        |
| 230 | + *  | 
                                                        |
| 231 | + * @param string $name  | 
                                                        |
| 232 | + *  | 
                                                        |
| 233 | + * @return mixed  | 
                                                        |
| 234 | + *  | 
                                                        |
| 235 | + * @throws PropertyDoesNotExistException If property isn't found.  | 
                                                        |
| 236 | + */  | 
                                                        |
| 237 | +    protected function get_attribute( $name ) { | 
                                                        |
| 238 | +        if ( 'type' === $name ) { | 
                                                        |
| 239 | + return $this->type;  | 
                                                        |
| 240 | + }  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | +        if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 243 | +            $value = $this->attributes['post']->{$this->{$method}()}; | 
                                                        |
| 244 | +        } else { | 
                                                        |
| 245 | +            if ( ! isset( $this->attributes['table'][ $name ] ) ) { | 
                                                        |
| 246 | + throw new PropertyDoesNotExistException;  | 
                                                        |
| 247 | + }  | 
                                                        |
| 248 | +  | 
                                                        |
| 249 | + $value = $this->attributes['table'][ $name ];  | 
                                                        |
| 250 | + }  | 
                                                        |
| 251 | +  | 
                                                        |
| 252 | + return $value;  | 
                                                        |
| 253 | +  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | +  | 
                                                        |
| 256 | + /**  | 
                                                        |
| 257 | + * Checks whether the attribute has a map method.  | 
                                                        |
| 258 | + *  | 
                                                        |
| 259 | + * This is used to determine whether the attribute maps to a  | 
                                                        |
| 260 | + * property on the underlying WP_Post object. Returns the  | 
                                                        |
| 261 | + * method if one exists, returns false if it doesn't.  | 
                                                        |
| 262 | + *  | 
                                                        |
| 263 | + * @param string $name  | 
                                                        |
| 264 | + *  | 
                                                        |
| 265 | + * @return false|string  | 
                                                        |
| 266 | + */  | 
                                                        |
| 267 | +    protected function has_map_method( $name ) { | 
                                                        |
| 268 | +        if ( method_exists( $this, $method = "map_{$name}" ) ) { | 
                                                        |
| 269 | + return $method;  | 
                                                        |
| 270 | + }  | 
                                                        |
| 271 | +  | 
                                                        |
| 272 | + return false;  | 
                                                        |
| 273 | + }  | 
                                                        |
| 274 | 274 | }  | 
                                                        
@@ -66,12 +66,12 @@ discard block  | 
                                                    ||
| 66 | 66 | *  | 
                                                        
| 67 | 67 | * @param array <string, mixed> $attributes  | 
                                                        
| 68 | 68 | */  | 
                                                        
| 69 | -	public function __construct( array $attributes = array() ) { | 
                                                        |
| 70 | -		foreach ( $attributes as $name => $value ) { | 
                                                        |
| 71 | - $this->set_attribute( $name, $value );  | 
                                                        |
| 69 | +	public function __construct(array $attributes = array()) { | 
                                                        |
| 70 | +		foreach ($attributes as $name => $value) { | 
                                                        |
| 71 | + $this->set_attribute($name, $value);  | 
                                                        |
| 72 | 72 | }  | 
                                                        
| 73 | 73 | |
| 74 | -		if ( $this->post && ! isset( $this->attributes['post'] ) ) { | 
                                                        |
| 74 | +		if ($this->post && !isset($this->attributes['post'])) { | 
                                                        |
| 75 | 75 | $this->create_default_post();  | 
                                                        
| 76 | 76 | }  | 
                                                        
| 77 | 77 | }  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | * @return false|WP_Post  | 
                                                        
| 98 | 98 | */  | 
                                                        
| 99 | 99 |  	public function get_underlying_post() { | 
                                                        
| 100 | -		if ( isset( $this->attributes['post'] ) ) { | 
                                                        |
| 100 | +		if (isset($this->attributes['post'])) { | 
                                                        |
| 101 | 101 | return $this->attributes['post'];  | 
                                                        
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
@@ -112,8 +112,8 @@ discard block  | 
                                                    ||
| 112 | 112 | * @param string $name  | 
                                                        
| 113 | 113 | * @param mixed $value  | 
                                                        
| 114 | 114 | */  | 
                                                        
| 115 | -	public function __set( $name, $value ) { | 
                                                        |
| 116 | - $this->set_attribute( $name, $value );  | 
                                                        |
| 115 | +	public function __set($name, $value) { | 
                                                        |
| 116 | + $this->set_attribute($name, $value);  | 
                                                        |
| 117 | 117 | }  | 
                                                        
| 118 | 118 | |
| 119 | 119 | /**  | 
                                                        
@@ -126,24 +126,24 @@ discard block  | 
                                                    ||
| 126 | 126 | * @param string $name  | 
                                                        
| 127 | 127 | * @param mixed $value  | 
                                                        
| 128 | 128 | */  | 
                                                        
| 129 | -	private function set_attribute( $name, $value ) { | 
                                                        |
| 130 | -		if ( 'post' === $name ) { | 
                                                        |
| 131 | - $this->override_post( $value );  | 
                                                        |
| 129 | +	private function set_attribute($name, $value) { | 
                                                        |
| 130 | +		if ('post' === $name) { | 
                                                        |
| 131 | + $this->override_post($value);  | 
                                                        |
| 132 | 132 | |
| 133 | 133 | return;  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
| 136 | -		if ( ! $this->is_fillable( $name ) ) { | 
                                                        |
| 136 | +		if (!$this->is_fillable($name)) { | 
                                                        |
| 137 | 137 | return;  | 
                                                        
| 138 | 138 | }  | 
                                                        
| 139 | 139 | |
| 140 | -		if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 140 | +		if ($method = $this->has_map_method($name)) { | 
                                                        |
| 141 | 141 |  			$this->attributes['post']->{$this->{$method}()} = $value; | 
                                                        
| 142 | 142 | |
| 143 | 143 | return;  | 
                                                        
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
| 146 | - $this->attributes['table'][ $name ] = $value;  | 
                                                        |
| 146 | + $this->attributes['table'][$name] = $value;  | 
                                                        |
| 147 | 147 | }  | 
                                                        
| 148 | 148 | |
| 149 | 149 | /**  | 
                                                        
@@ -155,18 +155,18 @@ discard block  | 
                                                    ||
| 155 | 155 | *  | 
                                                        
| 156 | 156 | * @return bool  | 
                                                        
| 157 | 157 | */  | 
                                                        
| 158 | -	private function is_fillable( $name ) { | 
                                                        |
| 158 | +	private function is_fillable($name) { | 
                                                        |
| 159 | 159 | // `type` is not fillable at all.  | 
                                                        
| 160 | -		if ( 'type' === $name ) { | 
                                                        |
| 160 | +		if ('type' === $name) { | 
                                                        |
| 161 | 161 | return false;  | 
                                                        
| 162 | 162 | }  | 
                                                        
| 163 | 163 | |
| 164 | 164 | // If the `$fillable` array hasn't been defined, pass everything.  | 
                                                        
| 165 | -		if ( ! $this->fillable ) { | 
                                                        |
| 165 | +		if (!$this->fillable) { | 
                                                        |
| 166 | 166 | return true;  | 
                                                        
| 167 | 167 | }  | 
                                                        
| 168 | 168 | |
| 169 | - return in_array( $name, $this->fillable );  | 
                                                        |
| 169 | + return in_array($name, $this->fillable);  | 
                                                        |
| 170 | 170 | }  | 
                                                        
| 171 | 171 | |
| 172 | 172 | /**  | 
                                                        
@@ -176,8 +176,8 @@ discard block  | 
                                                    ||
| 176 | 176 | *  | 
                                                        
| 177 | 177 | * @param WP_Post $value  | 
                                                        
| 178 | 178 | */  | 
                                                        
| 179 | -	private function override_post( WP_Post $value ) { | 
                                                        |
| 180 | - $this->attributes['post'] = $this->enforce_post_defaults( $value );  | 
                                                        |
| 179 | +	private function override_post(WP_Post $value) { | 
                                                        |
| 180 | + $this->attributes['post'] = $this->enforce_post_defaults($value);  | 
                                                        |
| 181 | 181 | }  | 
                                                        
| 182 | 182 | |
| 183 | 183 | /**  | 
                                                        
@@ -187,7 +187,7 @@ discard block  | 
                                                    ||
| 187 | 187 | * and stores it in the attributes.  | 
                                                        
| 188 | 188 | */  | 
                                                        
| 189 | 189 |  	private function create_default_post() { | 
                                                        
| 190 | - $this->attributes['post'] = $this->enforce_post_defaults( new WP_Post( new stdClass ) );  | 
                                                        |
| 190 | + $this->attributes['post'] = $this->enforce_post_defaults(new WP_Post(new stdClass));  | 
                                                        |
| 191 | 191 | }  | 
                                                        
| 192 | 192 | |
| 193 | 193 | /**  | 
                                                        
@@ -201,8 +201,8 @@ discard block  | 
                                                    ||
| 201 | 201 | *  | 
                                                        
| 202 | 202 | * @return WP_Post  | 
                                                        
| 203 | 203 | */  | 
                                                        
| 204 | -	protected function enforce_post_defaults( WP_Post $post ) { | 
                                                        |
| 205 | -		if ( is_string( $this->type ) ) { | 
                                                        |
| 204 | +	protected function enforce_post_defaults(WP_Post $post) { | 
                                                        |
| 205 | +		if (is_string($this->type)) { | 
                                                        |
| 206 | 206 | $post->post_type = $this->type;  | 
                                                        
| 207 | 207 | }  | 
                                                        
| 208 | 208 | |
@@ -218,8 +218,8 @@ discard block  | 
                                                    ||
| 218 | 218 | *  | 
                                                        
| 219 | 219 | * @return mixed  | 
                                                        
| 220 | 220 | */  | 
                                                        
| 221 | -	public function __get( $name ) { | 
                                                        |
| 222 | - return $this->get_attribute( $name );  | 
                                                        |
| 221 | +	public function __get($name) { | 
                                                        |
| 222 | + return $this->get_attribute($name);  | 
                                                        |
| 223 | 223 | }  | 
                                                        
| 224 | 224 | |
| 225 | 225 | /**  | 
                                                        
@@ -234,19 +234,19 @@ discard block  | 
                                                    ||
| 234 | 234 | *  | 
                                                        
| 235 | 235 | * @throws PropertyDoesNotExistException If property isn't found.  | 
                                                        
| 236 | 236 | */  | 
                                                        
| 237 | -	protected function get_attribute( $name ) { | 
                                                        |
| 238 | -		if ( 'type' === $name ) { | 
                                                        |
| 237 | +	protected function get_attribute($name) { | 
                                                        |
| 238 | +		if ('type' === $name) { | 
                                                        |
| 239 | 239 | return $this->type;  | 
                                                        
| 240 | 240 | }  | 
                                                        
| 241 | 241 | |
| 242 | -		if ( $method = $this->has_map_method( $name ) ) { | 
                                                        |
| 242 | +		if ($method = $this->has_map_method($name)) { | 
                                                        |
| 243 | 243 |  			$value = $this->attributes['post']->{$this->{$method}()}; | 
                                                        
| 244 | 244 |  		} else { | 
                                                        
| 245 | -			if ( ! isset( $this->attributes['table'][ $name ] ) ) { | 
                                                        |
| 245 | +			if (!isset($this->attributes['table'][$name])) { | 
                                                        |
| 246 | 246 | throw new PropertyDoesNotExistException;  | 
                                                        
| 247 | 247 | }  | 
                                                        
| 248 | 248 | |
| 249 | - $value = $this->attributes['table'][ $name ];  | 
                                                        |
| 249 | + $value = $this->attributes['table'][$name];  | 
                                                        |
| 250 | 250 | }  | 
                                                        
| 251 | 251 | |
| 252 | 252 | return $value;  | 
                                                        
@@ -264,8 +264,8 @@ discard block  | 
                                                    ||
| 264 | 264 | *  | 
                                                        
| 265 | 265 | * @return false|string  | 
                                                        
| 266 | 266 | */  | 
                                                        
| 267 | -	protected function has_map_method( $name ) { | 
                                                        |
| 268 | -		if ( method_exists( $this, $method = "map_{$name}" ) ) { | 
                                                        |
| 267 | +	protected function has_map_method($name) { | 
                                                        |
| 268 | +		if (method_exists($this, $method = "map_{$name}")) { | 
                                                        |
| 269 | 269 | return $method;  | 
                                                        
| 270 | 270 | }  | 
                                                        
| 271 | 271 | |
@@ -14,100 +14,100 @@  | 
                                                    ||
| 14 | 14 | * @subpackage Core  | 
                                                        
| 15 | 15 | */  | 
                                                        
| 16 | 16 |  class Loader implements LoaderContract { | 
                                                        
| 17 | - /**  | 
                                                        |
| 18 | - * Array of action hooks to attach.  | 
                                                        |
| 19 | - *  | 
                                                        |
| 20 | - * @var array[]  | 
                                                        |
| 21 | - */  | 
                                                        |
| 22 | - protected $actions = array();  | 
                                                        |
| 17 | + /**  | 
                                                        |
| 18 | + * Array of action hooks to attach.  | 
                                                        |
| 19 | + *  | 
                                                        |
| 20 | + * @var array[]  | 
                                                        |
| 21 | + */  | 
                                                        |
| 22 | + protected $actions = array();  | 
                                                        |
| 23 | 23 | |
| 24 | - /**  | 
                                                        |
| 25 | - * Array of filter hooks to attach.  | 
                                                        |
| 26 | - *  | 
                                                        |
| 27 | - * @var array[]  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - protected $filters = array();  | 
                                                        |
| 24 | + /**  | 
                                                        |
| 25 | + * Array of filter hooks to attach.  | 
                                                        |
| 26 | + *  | 
                                                        |
| 27 | + * @var array[]  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + protected $filters = array();  | 
                                                        |
| 30 | 30 | |
| 31 | - /**  | 
                                                        |
| 32 | -	 * {@inheritDoc} | 
                                                        |
| 33 | - */  | 
                                                        |
| 34 | -	public function run() { | 
                                                        |
| 35 | -		foreach ( $this->actions as $action ) { | 
                                                        |
| 36 | - add_action(  | 
                                                        |
| 37 | - $action['hook'],  | 
                                                        |
| 38 | - array( $action['service'], $action['method'] ),  | 
                                                        |
| 39 | - $action['priority'],  | 
                                                        |
| 40 | - $action['args']  | 
                                                        |
| 41 | - );  | 
                                                        |
| 42 | - }  | 
                                                        |
| 31 | + /**  | 
                                                        |
| 32 | +     * {@inheritDoc} | 
                                                        |
| 33 | + */  | 
                                                        |
| 34 | +    public function run() { | 
                                                        |
| 35 | +        foreach ( $this->actions as $action ) { | 
                                                        |
| 36 | + add_action(  | 
                                                        |
| 37 | + $action['hook'],  | 
                                                        |
| 38 | + array( $action['service'], $action['method'] ),  | 
                                                        |
| 39 | + $action['priority'],  | 
                                                        |
| 40 | + $action['args']  | 
                                                        |
| 41 | + );  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | 43 | |
| 44 | -		foreach ( $this->filters as $filter ) { | 
                                                        |
| 45 | - add_filter(  | 
                                                        |
| 46 | - $filter['hook'],  | 
                                                        |
| 47 | - array( $filter['service'], $filter['method'] ),  | 
                                                        |
| 48 | - $filter['priority'],  | 
                                                        |
| 49 | - $filter['args']  | 
                                                        |
| 50 | - );  | 
                                                        |
| 51 | - }  | 
                                                        |
| 52 | - }  | 
                                                        |
| 44 | +        foreach ( $this->filters as $filter ) { | 
                                                        |
| 45 | + add_filter(  | 
                                                        |
| 46 | + $filter['hook'],  | 
                                                        |
| 47 | + array( $filter['service'], $filter['method'] ),  | 
                                                        |
| 48 | + $filter['priority'],  | 
                                                        |
| 49 | + $filter['args']  | 
                                                        |
| 50 | + );  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | + }  | 
                                                        |
| 53 | 53 | |
| 54 | - /**  | 
                                                        |
| 55 | - * Registers a single Service's actions with WordPress.  | 
                                                        |
| 56 | - *  | 
                                                        |
| 57 | - * @param HasActions $service  | 
                                                        |
| 58 | - */  | 
                                                        |
| 59 | -	public function register_actions( HasActions $service ) { | 
                                                        |
| 60 | -		foreach ( $service->action_hooks() as $action ) { | 
                                                        |
| 61 | - $this->actions = $this->add(  | 
                                                        |
| 62 | - $this->actions,  | 
                                                        |
| 63 | - $action['hook'],  | 
                                                        |
| 64 | - $service,  | 
                                                        |
| 65 | - $action['method'],  | 
                                                        |
| 66 | - isset( $action['priority'] ) ? $action['priority'] : 10,  | 
                                                        |
| 67 | - isset( $action['args'] ) ? $action['args'] : 1  | 
                                                        |
| 68 | - );  | 
                                                        |
| 69 | - }  | 
                                                        |
| 70 | - }  | 
                                                        |
| 54 | + /**  | 
                                                        |
| 55 | + * Registers a single Service's actions with WordPress.  | 
                                                        |
| 56 | + *  | 
                                                        |
| 57 | + * @param HasActions $service  | 
                                                        |
| 58 | + */  | 
                                                        |
| 59 | +    public function register_actions( HasActions $service ) { | 
                                                        |
| 60 | +        foreach ( $service->action_hooks() as $action ) { | 
                                                        |
| 61 | + $this->actions = $this->add(  | 
                                                        |
| 62 | + $this->actions,  | 
                                                        |
| 63 | + $action['hook'],  | 
                                                        |
| 64 | + $service,  | 
                                                        |
| 65 | + $action['method'],  | 
                                                        |
| 66 | + isset( $action['priority'] ) ? $action['priority'] : 10,  | 
                                                        |
| 67 | + isset( $action['args'] ) ? $action['args'] : 1  | 
                                                        |
| 68 | + );  | 
                                                        |
| 69 | + }  | 
                                                        |
| 70 | + }  | 
                                                        |
| 71 | 71 | |
| 72 | - /**  | 
                                                        |
| 73 | - * Registers a single Service's filters with WordPress.  | 
                                                        |
| 74 | - *  | 
                                                        |
| 75 | - * @param HasFilters $service  | 
                                                        |
| 76 | - */  | 
                                                        |
| 77 | -	public function register_filters( HasFilters $service ) { | 
                                                        |
| 78 | -		foreach ( $service->filter_hooks() as $filter ) { | 
                                                        |
| 79 | - $this->filters = $this->add(  | 
                                                        |
| 80 | - $this->filters,  | 
                                                        |
| 81 | - $filter['hook'],  | 
                                                        |
| 82 | - $service,  | 
                                                        |
| 83 | - $filter['method'],  | 
                                                        |
| 84 | - isset( $filter['priority'] ) ? $filter['priority'] : 10,  | 
                                                        |
| 85 | - isset( $filter['args'] ) ? $filter['args'] : 1  | 
                                                        |
| 86 | - );  | 
                                                        |
| 87 | - }  | 
                                                        |
| 88 | - }  | 
                                                        |
| 72 | + /**  | 
                                                        |
| 73 | + * Registers a single Service's filters with WordPress.  | 
                                                        |
| 74 | + *  | 
                                                        |
| 75 | + * @param HasFilters $service  | 
                                                        |
| 76 | + */  | 
                                                        |
| 77 | +    public function register_filters( HasFilters $service ) { | 
                                                        |
| 78 | +        foreach ( $service->filter_hooks() as $filter ) { | 
                                                        |
| 79 | + $this->filters = $this->add(  | 
                                                        |
| 80 | + $this->filters,  | 
                                                        |
| 81 | + $filter['hook'],  | 
                                                        |
| 82 | + $service,  | 
                                                        |
| 83 | + $filter['method'],  | 
                                                        |
| 84 | + isset( $filter['priority'] ) ? $filter['priority'] : 10,  | 
                                                        |
| 85 | + isset( $filter['args'] ) ? $filter['args'] : 1  | 
                                                        |
| 86 | + );  | 
                                                        |
| 87 | + }  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | 89 | |
| 90 | - /**  | 
                                                        |
| 91 | - * Utility to register the actions and hooks into a single collection.  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - * @param array $hooks  | 
                                                        |
| 94 | - * @param string $hook  | 
                                                        |
| 95 | - * @param object $service  | 
                                                        |
| 96 | - * @param string $method  | 
                                                        |
| 97 | - * @param int $priority  | 
                                                        |
| 98 | - * @param int $accepted_args  | 
                                                        |
| 99 | - *  | 
                                                        |
| 100 | - * @return array  | 
                                                        |
| 101 | - */  | 
                                                        |
| 102 | -	protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { | 
                                                        |
| 103 | - $hooks[] = array(  | 
                                                        |
| 104 | - 'hook' => $hook,  | 
                                                        |
| 105 | - 'service' => $service,  | 
                                                        |
| 106 | - 'method' => $method,  | 
                                                        |
| 107 | - 'priority' => $priority,  | 
                                                        |
| 108 | - 'args' => $accepted_args,  | 
                                                        |
| 109 | - );  | 
                                                        |
| 90 | + /**  | 
                                                        |
| 91 | + * Utility to register the actions and hooks into a single collection.  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + * @param array $hooks  | 
                                                        |
| 94 | + * @param string $hook  | 
                                                        |
| 95 | + * @param object $service  | 
                                                        |
| 96 | + * @param string $method  | 
                                                        |
| 97 | + * @param int $priority  | 
                                                        |
| 98 | + * @param int $accepted_args  | 
                                                        |
| 99 | + *  | 
                                                        |
| 100 | + * @return array  | 
                                                        |
| 101 | + */  | 
                                                        |
| 102 | +    protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { | 
                                                        |
| 103 | + $hooks[] = array(  | 
                                                        |
| 104 | + 'hook' => $hook,  | 
                                                        |
| 105 | + 'service' => $service,  | 
                                                        |
| 106 | + 'method' => $method,  | 
                                                        |
| 107 | + 'priority' => $priority,  | 
                                                        |
| 108 | + 'args' => $accepted_args,  | 
                                                        |
| 109 | + );  | 
                                                        |
| 110 | 110 | |
| 111 | - return $hooks;  | 
                                                        |
| 112 | - }  | 
                                                        |
| 111 | + return $hooks;  | 
                                                        |
| 112 | + }  | 
                                                        |
| 113 | 113 | }  | 
                                                        
@@ -32,19 +32,19 @@ discard block  | 
                                                    ||
| 32 | 32 |  	 * {@inheritDoc} | 
                                                        
| 33 | 33 | */  | 
                                                        
| 34 | 34 |  	public function run() { | 
                                                        
| 35 | -		foreach ( $this->actions as $action ) { | 
                                                        |
| 35 | +		foreach ($this->actions as $action) { | 
                                                        |
| 36 | 36 | add_action(  | 
                                                        
| 37 | 37 | $action['hook'],  | 
                                                        
| 38 | - array( $action['service'], $action['method'] ),  | 
                                                        |
| 38 | + array($action['service'], $action['method']),  | 
                                                        |
| 39 | 39 | $action['priority'],  | 
                                                        
| 40 | 40 | $action['args']  | 
                                                        
| 41 | 41 | );  | 
                                                        
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | -		foreach ( $this->filters as $filter ) { | 
                                                        |
| 44 | +		foreach ($this->filters as $filter) { | 
                                                        |
| 45 | 45 | add_filter(  | 
                                                        
| 46 | 46 | $filter['hook'],  | 
                                                        
| 47 | - array( $filter['service'], $filter['method'] ),  | 
                                                        |
| 47 | + array($filter['service'], $filter['method']),  | 
                                                        |
| 48 | 48 | $filter['priority'],  | 
                                                        
| 49 | 49 | $filter['args']  | 
                                                        
| 50 | 50 | );  | 
                                                        
@@ -56,15 +56,15 @@ discard block  | 
                                                    ||
| 56 | 56 | *  | 
                                                        
| 57 | 57 | * @param HasActions $service  | 
                                                        
| 58 | 58 | */  | 
                                                        
| 59 | -	public function register_actions( HasActions $service ) { | 
                                                        |
| 60 | -		foreach ( $service->action_hooks() as $action ) { | 
                                                        |
| 59 | +	public function register_actions(HasActions $service) { | 
                                                        |
| 60 | +		foreach ($service->action_hooks() as $action) { | 
                                                        |
| 61 | 61 | $this->actions = $this->add(  | 
                                                        
| 62 | 62 | $this->actions,  | 
                                                        
| 63 | 63 | $action['hook'],  | 
                                                        
| 64 | 64 | $service,  | 
                                                        
| 65 | 65 | $action['method'],  | 
                                                        
| 66 | - isset( $action['priority'] ) ? $action['priority'] : 10,  | 
                                                        |
| 67 | - isset( $action['args'] ) ? $action['args'] : 1  | 
                                                        |
| 66 | + isset($action['priority']) ? $action['priority'] : 10,  | 
                                                        |
| 67 | + isset($action['args']) ? $action['args'] : 1  | 
                                                        |
| 68 | 68 | );  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | }  | 
                                                        
@@ -74,15 +74,15 @@ discard block  | 
                                                    ||
| 74 | 74 | *  | 
                                                        
| 75 | 75 | * @param HasFilters $service  | 
                                                        
| 76 | 76 | */  | 
                                                        
| 77 | -	public function register_filters( HasFilters $service ) { | 
                                                        |
| 78 | -		foreach ( $service->filter_hooks() as $filter ) { | 
                                                        |
| 77 | +	public function register_filters(HasFilters $service) { | 
                                                        |
| 78 | +		foreach ($service->filter_hooks() as $filter) { | 
                                                        |
| 79 | 79 | $this->filters = $this->add(  | 
                                                        
| 80 | 80 | $this->filters,  | 
                                                        
| 81 | 81 | $filter['hook'],  | 
                                                        
| 82 | 82 | $service,  | 
                                                        
| 83 | 83 | $filter['method'],  | 
                                                        
| 84 | - isset( $filter['priority'] ) ? $filter['priority'] : 10,  | 
                                                        |
| 85 | - isset( $filter['args'] ) ? $filter['args'] : 1  | 
                                                        |
| 84 | + isset($filter['priority']) ? $filter['priority'] : 10,  | 
                                                        |
| 85 | + isset($filter['args']) ? $filter['args'] : 1  | 
                                                        |
| 86 | 86 | );  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | }  | 
                                                        
@@ -99,7 +99,7 @@ discard block  | 
                                                    ||
| 99 | 99 | *  | 
                                                        
| 100 | 100 | * @return array  | 
                                                        
| 101 | 101 | */  | 
                                                        
| 102 | -	protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { | 
                                                        |
| 102 | +	protected function add($hooks, $hook, $service, $method, $priority, $accepted_args) { | 
                                                        |
| 103 | 103 | $hooks[] = array(  | 
                                                        
| 104 | 104 | 'hook' => $hook,  | 
                                                        
| 105 | 105 | 'service' => $service,  | 
                                                        
@@ -13,309 +13,309 @@  | 
                                                    ||
| 13 | 13 | * @subpackage Core  | 
                                                        
| 14 | 14 | */  | 
                                                        
| 15 | 15 |  class Container implements ContainerContract { | 
                                                        
| 16 | - /**  | 
                                                        |
| 17 | - * Registered definitions.  | 
                                                        |
| 18 | - *  | 
                                                        |
| 19 | - * @var mixed[]  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - private $definitions = array();  | 
                                                        |
| 22 | -  | 
                                                        |
| 23 | - /**  | 
                                                        |
| 24 | - * Aliases to share between fetches.  | 
                                                        |
| 25 | - *  | 
                                                        |
| 26 | - * @var <string, true>[]  | 
                                                        |
| 27 | - */  | 
                                                        |
| 28 | - private $shared = array();  | 
                                                        |
| 29 | -  | 
                                                        |
| 30 | - /**  | 
                                                        |
| 31 | - * Aliases of all the registered services.  | 
                                                        |
| 32 | - *  | 
                                                        |
| 33 | - * @var <string, true>[]  | 
                                                        |
| 34 | - */  | 
                                                        |
| 35 | - private $aliases = array();  | 
                                                        |
| 36 | -  | 
                                                        |
| 37 | - /**  | 
                                                        |
| 38 | - * Array of classes registered on the container.  | 
                                                        |
| 39 | - *  | 
                                                        |
| 40 | - * @var <string, true>[]  | 
                                                        |
| 41 | - */  | 
                                                        |
| 42 | - private $classes = array();  | 
                                                        |
| 43 | -  | 
                                                        |
| 44 | - /**  | 
                                                        |
| 45 | - * Current position in the loop.  | 
                                                        |
| 46 | - *  | 
                                                        |
| 47 | - * @var int  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | - private $position;  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | - /**  | 
                                                        |
| 52 | - * 0-indexed array of aliases for looping.  | 
                                                        |
| 53 | - *  | 
                                                        |
| 54 | - * @var string[]  | 
                                                        |
| 55 | - */  | 
                                                        |
| 56 | - private $keys = array();  | 
                                                        |
| 57 | -  | 
                                                        |
| 58 | - /**  | 
                                                        |
| 59 | - * Create a new container with the given providers.  | 
                                                        |
| 60 | - *  | 
                                                        |
| 61 | - * Providers can be instances or the class of the provider as a string.  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * @param ServiceProvider[]|string[] $providers  | 
                                                        |
| 64 | - */  | 
                                                        |
| 65 | -	public function __construct( array $providers = array() ) { | 
                                                        |
| 66 | -		foreach ( $providers as $provider ) { | 
                                                        |
| 67 | -			if ( is_string( $provider ) && class_exists( $provider ) ) { | 
                                                        |
| 68 | - $provider = new $provider;  | 
                                                        |
| 69 | - }  | 
                                                        |
| 70 | -  | 
                                                        |
| 71 | -			if ( $provider instanceof ServiceProvider ) { | 
                                                        |
| 72 | - $this->register( $provider );  | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | - }  | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | -  | 
                                                        |
| 78 | - /**  | 
                                                        |
| 79 | -	 * {@inheritdoc} | 
                                                        |
| 80 | - *  | 
                                                        |
| 81 | - * @param string|array $alias  | 
                                                        |
| 82 | - * @param mixed $definition  | 
                                                        |
| 83 | - *  | 
                                                        |
| 84 | - * @throws DefinedAliasException  | 
                                                        |
| 85 | - *  | 
                                                        |
| 86 | - * @return $this  | 
                                                        |
| 87 | - */  | 
                                                        |
| 88 | -	public function define( $alias, $definition ) { | 
                                                        |
| 89 | -		if ( is_array( $alias ) ) { | 
                                                        |
| 90 | - $class = current( $alias );  | 
                                                        |
| 91 | - $alias = key( $alias );  | 
                                                        |
| 92 | - }  | 
                                                        |
| 93 | -  | 
                                                        |
| 94 | -		if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 95 | - throw new DefinedAliasException;  | 
                                                        |
| 96 | - }  | 
                                                        |
| 97 | -  | 
                                                        |
| 98 | - $this->aliases[ $alias ] = true;  | 
                                                        |
| 99 | - $this->definitions[ $alias ] = $definition;  | 
                                                        |
| 100 | -  | 
                                                        |
| 101 | - // Closures are treated as factories unless  | 
                                                        |
| 102 | - // defined via Container::share.  | 
                                                        |
| 103 | -		if ( ! $definition instanceof \Closure ) { | 
                                                        |
| 104 | - $this->shared[ $alias ] = true;  | 
                                                        |
| 105 | - }  | 
                                                        |
| 106 | -  | 
                                                        |
| 107 | -		if ( isset( $class ) ) { | 
                                                        |
| 108 | - $this->classes[ $class ] = $alias;  | 
                                                        |
| 109 | - }  | 
                                                        |
| 110 | -  | 
                                                        |
| 111 | - return $this;  | 
                                                        |
| 112 | - }  | 
                                                        |
| 113 | -  | 
                                                        |
| 114 | - /**  | 
                                                        |
| 115 | -	 * {@inheritdoc} | 
                                                        |
| 116 | - *  | 
                                                        |
| 117 | - * @param string|array $alias  | 
                                                        |
| 118 | - * @param mixed $definition  | 
                                                        |
| 119 | - *  | 
                                                        |
| 120 | - * @throws DefinedAliasException  | 
                                                        |
| 121 | - *  | 
                                                        |
| 122 | - * @return $this  | 
                                                        |
| 123 | - */  | 
                                                        |
| 124 | -	public function share( $alias, $definition ) { | 
                                                        |
| 125 | - $this->define( $alias, $definition );  | 
                                                        |
| 126 | -  | 
                                                        |
| 127 | -		if ( is_array( $alias ) ) { | 
                                                        |
| 128 | - $alias = key( $alias );  | 
                                                        |
| 129 | - }  | 
                                                        |
| 130 | -  | 
                                                        |
| 131 | - $this->shared[ $alias ] = true;  | 
                                                        |
| 132 | -  | 
                                                        |
| 133 | - return $this;  | 
                                                        |
| 134 | - }  | 
                                                        |
| 135 | -  | 
                                                        |
| 136 | - /**  | 
                                                        |
| 137 | -	 * {@inheritdoc} | 
                                                        |
| 138 | - *  | 
                                                        |
| 139 | - * @param string $alias  | 
                                                        |
| 140 | - *  | 
                                                        |
| 141 | - * @throws UndefinedAliasException  | 
                                                        |
| 142 | - *  | 
                                                        |
| 143 | - * @return mixed  | 
                                                        |
| 144 | - */  | 
                                                        |
| 145 | -	public function fetch( $alias ) { | 
                                                        |
| 146 | -		if ( isset( $this->classes[ $alias ] ) ) { | 
                                                        |
| 147 | - // If the alias is a class name,  | 
                                                        |
| 148 | - // then retrieve its linked alias.  | 
                                                        |
| 149 | - // This is only registered when  | 
                                                        |
| 150 | - // registering using an array.  | 
                                                        |
| 151 | - $alias = $this->classes[ $alias ];  | 
                                                        |
| 152 | - }  | 
                                                        |
| 153 | -  | 
                                                        |
| 154 | -		if ( ! isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 155 | - throw new UndefinedAliasException;  | 
                                                        |
| 156 | - }  | 
                                                        |
| 157 | -  | 
                                                        |
| 158 | - $value = $this->definitions[ $alias ];  | 
                                                        |
| 159 | -  | 
                                                        |
| 160 | - // If the shared value is a closure,  | 
                                                        |
| 161 | - // execute it and assign the result  | 
                                                        |
| 162 | - // in place of the closure.  | 
                                                        |
| 163 | -		if ( $value instanceof \Closure ) { | 
                                                        |
| 164 | - $factory = $value;  | 
                                                        |
| 165 | - $value = $factory( $this );  | 
                                                        |
| 166 | - }  | 
                                                        |
| 167 | -  | 
                                                        |
| 168 | - // If the value is shared, save the shared value.  | 
                                                        |
| 169 | -		if ( isset( $this->shared[ $alias ] ) ) { | 
                                                        |
| 170 | - $this->definitions[ $alias ] = $value;  | 
                                                        |
| 171 | - }  | 
                                                        |
| 172 | -  | 
                                                        |
| 173 | - // Return the fetched value.  | 
                                                        |
| 174 | - return $value;  | 
                                                        |
| 175 | - }  | 
                                                        |
| 176 | -  | 
                                                        |
| 177 | - /**  | 
                                                        |
| 178 | -	 * {@inheritdoc} | 
                                                        |
| 179 | - *  | 
                                                        |
| 180 | - * @param string $alias  | 
                                                        |
| 181 | - *  | 
                                                        |
| 182 | - * @return bool  | 
                                                        |
| 183 | - */  | 
                                                        |
| 184 | -	public function has( $alias ) { | 
                                                        |
| 185 | - return isset( $this->aliases[ $alias ] );  | 
                                                        |
| 186 | - }  | 
                                                        |
| 187 | -  | 
                                                        |
| 188 | - /**  | 
                                                        |
| 189 | -	 * {@inheritDoc} | 
                                                        |
| 190 | - *  | 
                                                        |
| 191 | - * @param string $alias  | 
                                                        |
| 192 | - *  | 
                                                        |
| 193 | - * @return $this  | 
                                                        |
| 194 | - */  | 
                                                        |
| 195 | -	public function remove( $alias ) { | 
                                                        |
| 196 | -		if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 197 | - /**  | 
                                                        |
| 198 | - * If there's no reference in the aliases array,  | 
                                                        |
| 199 | - * the service won't be found on fetching and  | 
                                                        |
| 200 | - * can be overwritten on setting.  | 
                                                        |
| 201 | - *  | 
                                                        |
| 202 | - * Pros: Quick setting/unsetting, faster  | 
                                                        |
| 203 | - * performance on those operations when doing  | 
                                                        |
| 204 | - * a lot of these.  | 
                                                        |
| 205 | - *  | 
                                                        |
| 206 | - * Cons: Objects and values set in the container  | 
                                                        |
| 207 | - * can't get garbage collected.  | 
                                                        |
| 208 | - *  | 
                                                        |
| 209 | - * If this is a problem, this may need to be revisited.  | 
                                                        |
| 210 | - */  | 
                                                        |
| 211 | - unset( $this->aliases[ $alias ] );  | 
                                                        |
| 212 | - }  | 
                                                        |
| 213 | -  | 
                                                        |
| 214 | - return $this;  | 
                                                        |
| 215 | - }  | 
                                                        |
| 216 | -  | 
                                                        |
| 217 | - /**  | 
                                                        |
| 218 | -	 * {@inheritDoc} | 
                                                        |
| 219 | - *  | 
                                                        |
| 220 | - * @param ServiceProvider $provider  | 
                                                        |
| 221 | - *  | 
                                                        |
| 222 | - * @return $this  | 
                                                        |
| 223 | - */  | 
                                                        |
| 224 | -	public function register( ServiceProvider $provider ) { | 
                                                        |
| 225 | - $provider->register( $this );  | 
                                                        |
| 226 | -  | 
                                                        |
| 227 | - return $this;  | 
                                                        |
| 228 | - }  | 
                                                        |
| 229 | -  | 
                                                        |
| 230 | - /**  | 
                                                        |
| 231 | - * Set a value into the container.  | 
                                                        |
| 232 | - *  | 
                                                        |
| 233 | - * @param string $id  | 
                                                        |
| 234 | - * @param mixed $value  | 
                                                        |
| 235 | - *  | 
                                                        |
| 236 | - * @see define  | 
                                                        |
| 237 | - */  | 
                                                        |
| 238 | -	public function offsetSet( $id, $value ) { | 
                                                        |
| 239 | - $this->define( $id, $value );  | 
                                                        |
| 240 | - }  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | - /**  | 
                                                        |
| 243 | - * Get an value from the container.  | 
                                                        |
| 244 | - *  | 
                                                        |
| 245 | - * @param string $id  | 
                                                        |
| 246 | - *  | 
                                                        |
| 247 | - * @return object  | 
                                                        |
| 248 | - * @throws UndefinedAliasException  | 
                                                        |
| 249 | - *  | 
                                                        |
| 250 | - * @see fetch  | 
                                                        |
| 251 | - */  | 
                                                        |
| 252 | -	public function offsetGet( $id ) { | 
                                                        |
| 253 | - return $this->fetch( $id );  | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | -  | 
                                                        |
| 256 | - /**  | 
                                                        |
| 257 | - * Checks if a key is set on the container.  | 
                                                        |
| 258 | - *  | 
                                                        |
| 259 | - * @param string $id  | 
                                                        |
| 260 | - *  | 
                                                        |
| 261 | - * @return bool  | 
                                                        |
| 262 | - *  | 
                                                        |
| 263 | - * @see has  | 
                                                        |
| 264 | - */  | 
                                                        |
| 265 | -	public function offsetExists( $id ) { | 
                                                        |
| 266 | - return $this->has( $id );  | 
                                                        |
| 267 | - }  | 
                                                        |
| 268 | -  | 
                                                        |
| 269 | - /**  | 
                                                        |
| 270 | - * Remove a key from the container.  | 
                                                        |
| 271 | - *  | 
                                                        |
| 272 | - * @param string $id  | 
                                                        |
| 273 | - *  | 
                                                        |
| 274 | - * @see remove  | 
                                                        |
| 275 | - */  | 
                                                        |
| 276 | -	public function offsetUnset( $id ) { | 
                                                        |
| 277 | - $this->remove( $id );  | 
                                                        |
| 278 | - }  | 
                                                        |
| 279 | -  | 
                                                        |
| 280 | - /**  | 
                                                        |
| 281 | - * Sets the object properties to prepare for the loop.  | 
                                                        |
| 282 | - */  | 
                                                        |
| 283 | -	public function rewind() { | 
                                                        |
| 284 | - $this->position = 0;  | 
                                                        |
| 285 | - $this->keys = array_keys( $this->aliases );  | 
                                                        |
| 286 | - }  | 
                                                        |
| 287 | -  | 
                                                        |
| 288 | - /**  | 
                                                        |
| 289 | - * Retrieves the service object for the current step in the loop.  | 
                                                        |
| 290 | - *  | 
                                                        |
| 291 | - * @return object  | 
                                                        |
| 292 | - */  | 
                                                        |
| 293 | -	public function current() { | 
                                                        |
| 294 | - return $this->fetch( $this->keys[ $this->position ] );  | 
                                                        |
| 295 | - }  | 
                                                        |
| 296 | -  | 
                                                        |
| 297 | - /**  | 
                                                        |
| 298 | - * Retrieves the key for the current step in the loop.  | 
                                                        |
| 299 | - *  | 
                                                        |
| 300 | - * @return string  | 
                                                        |
| 301 | - */  | 
                                                        |
| 302 | -	public function key() { | 
                                                        |
| 303 | - return $this->keys[ $this->position ];  | 
                                                        |
| 304 | - }  | 
                                                        |
| 305 | -  | 
                                                        |
| 306 | - /**  | 
                                                        |
| 307 | - * Increments to the next step in the loop.  | 
                                                        |
| 308 | - */  | 
                                                        |
| 309 | -	public function next() { | 
                                                        |
| 310 | - $this->position ++;  | 
                                                        |
| 311 | - }  | 
                                                        |
| 312 | -  | 
                                                        |
| 313 | - /**  | 
                                                        |
| 314 | - * Checks if the next step in the loop in valid.  | 
                                                        |
| 315 | - *  | 
                                                        |
| 316 | - * @return bool  | 
                                                        |
| 317 | - */  | 
                                                        |
| 318 | -	public function valid() { | 
                                                        |
| 319 | - return isset( $this->keys[ $this->position ] );  | 
                                                        |
| 320 | - }  | 
                                                        |
| 16 | + /**  | 
                                                        |
| 17 | + * Registered definitions.  | 
                                                        |
| 18 | + *  | 
                                                        |
| 19 | + * @var mixed[]  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + private $definitions = array();  | 
                                                        |
| 22 | +  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * Aliases to share between fetches.  | 
                                                        |
| 25 | + *  | 
                                                        |
| 26 | + * @var <string, true>[]  | 
                                                        |
| 27 | + */  | 
                                                        |
| 28 | + private $shared = array();  | 
                                                        |
| 29 | +  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * Aliases of all the registered services.  | 
                                                        |
| 32 | + *  | 
                                                        |
| 33 | + * @var <string, true>[]  | 
                                                        |
| 34 | + */  | 
                                                        |
| 35 | + private $aliases = array();  | 
                                                        |
| 36 | +  | 
                                                        |
| 37 | + /**  | 
                                                        |
| 38 | + * Array of classes registered on the container.  | 
                                                        |
| 39 | + *  | 
                                                        |
| 40 | + * @var <string, true>[]  | 
                                                        |
| 41 | + */  | 
                                                        |
| 42 | + private $classes = array();  | 
                                                        |
| 43 | +  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * Current position in the loop.  | 
                                                        |
| 46 | + *  | 
                                                        |
| 47 | + * @var int  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | + private $position;  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * 0-indexed array of aliases for looping.  | 
                                                        |
| 53 | + *  | 
                                                        |
| 54 | + * @var string[]  | 
                                                        |
| 55 | + */  | 
                                                        |
| 56 | + private $keys = array();  | 
                                                        |
| 57 | +  | 
                                                        |
| 58 | + /**  | 
                                                        |
| 59 | + * Create a new container with the given providers.  | 
                                                        |
| 60 | + *  | 
                                                        |
| 61 | + * Providers can be instances or the class of the provider as a string.  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * @param ServiceProvider[]|string[] $providers  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | +    public function __construct( array $providers = array() ) { | 
                                                        |
| 66 | +        foreach ( $providers as $provider ) { | 
                                                        |
| 67 | +            if ( is_string( $provider ) && class_exists( $provider ) ) { | 
                                                        |
| 68 | + $provider = new $provider;  | 
                                                        |
| 69 | + }  | 
                                                        |
| 70 | +  | 
                                                        |
| 71 | +            if ( $provider instanceof ServiceProvider ) { | 
                                                        |
| 72 | + $this->register( $provider );  | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | +  | 
                                                        |
| 78 | + /**  | 
                                                        |
| 79 | +     * {@inheritdoc} | 
                                                        |
| 80 | + *  | 
                                                        |
| 81 | + * @param string|array $alias  | 
                                                        |
| 82 | + * @param mixed $definition  | 
                                                        |
| 83 | + *  | 
                                                        |
| 84 | + * @throws DefinedAliasException  | 
                                                        |
| 85 | + *  | 
                                                        |
| 86 | + * @return $this  | 
                                                        |
| 87 | + */  | 
                                                        |
| 88 | +    public function define( $alias, $definition ) { | 
                                                        |
| 89 | +        if ( is_array( $alias ) ) { | 
                                                        |
| 90 | + $class = current( $alias );  | 
                                                        |
| 91 | + $alias = key( $alias );  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | +  | 
                                                        |
| 94 | +        if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 95 | + throw new DefinedAliasException;  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | +  | 
                                                        |
| 98 | + $this->aliases[ $alias ] = true;  | 
                                                        |
| 99 | + $this->definitions[ $alias ] = $definition;  | 
                                                        |
| 100 | +  | 
                                                        |
| 101 | + // Closures are treated as factories unless  | 
                                                        |
| 102 | + // defined via Container::share.  | 
                                                        |
| 103 | +        if ( ! $definition instanceof \Closure ) { | 
                                                        |
| 104 | + $this->shared[ $alias ] = true;  | 
                                                        |
| 105 | + }  | 
                                                        |
| 106 | +  | 
                                                        |
| 107 | +        if ( isset( $class ) ) { | 
                                                        |
| 108 | + $this->classes[ $class ] = $alias;  | 
                                                        |
| 109 | + }  | 
                                                        |
| 110 | +  | 
                                                        |
| 111 | + return $this;  | 
                                                        |
| 112 | + }  | 
                                                        |
| 113 | +  | 
                                                        |
| 114 | + /**  | 
                                                        |
| 115 | +     * {@inheritdoc} | 
                                                        |
| 116 | + *  | 
                                                        |
| 117 | + * @param string|array $alias  | 
                                                        |
| 118 | + * @param mixed $definition  | 
                                                        |
| 119 | + *  | 
                                                        |
| 120 | + * @throws DefinedAliasException  | 
                                                        |
| 121 | + *  | 
                                                        |
| 122 | + * @return $this  | 
                                                        |
| 123 | + */  | 
                                                        |
| 124 | +    public function share( $alias, $definition ) { | 
                                                        |
| 125 | + $this->define( $alias, $definition );  | 
                                                        |
| 126 | +  | 
                                                        |
| 127 | +        if ( is_array( $alias ) ) { | 
                                                        |
| 128 | + $alias = key( $alias );  | 
                                                        |
| 129 | + }  | 
                                                        |
| 130 | +  | 
                                                        |
| 131 | + $this->shared[ $alias ] = true;  | 
                                                        |
| 132 | +  | 
                                                        |
| 133 | + return $this;  | 
                                                        |
| 134 | + }  | 
                                                        |
| 135 | +  | 
                                                        |
| 136 | + /**  | 
                                                        |
| 137 | +     * {@inheritdoc} | 
                                                        |
| 138 | + *  | 
                                                        |
| 139 | + * @param string $alias  | 
                                                        |
| 140 | + *  | 
                                                        |
| 141 | + * @throws UndefinedAliasException  | 
                                                        |
| 142 | + *  | 
                                                        |
| 143 | + * @return mixed  | 
                                                        |
| 144 | + */  | 
                                                        |
| 145 | +    public function fetch( $alias ) { | 
                                                        |
| 146 | +        if ( isset( $this->classes[ $alias ] ) ) { | 
                                                        |
| 147 | + // If the alias is a class name,  | 
                                                        |
| 148 | + // then retrieve its linked alias.  | 
                                                        |
| 149 | + // This is only registered when  | 
                                                        |
| 150 | + // registering using an array.  | 
                                                        |
| 151 | + $alias = $this->classes[ $alias ];  | 
                                                        |
| 152 | + }  | 
                                                        |
| 153 | +  | 
                                                        |
| 154 | +        if ( ! isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 155 | + throw new UndefinedAliasException;  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | +  | 
                                                        |
| 158 | + $value = $this->definitions[ $alias ];  | 
                                                        |
| 159 | +  | 
                                                        |
| 160 | + // If the shared value is a closure,  | 
                                                        |
| 161 | + // execute it and assign the result  | 
                                                        |
| 162 | + // in place of the closure.  | 
                                                        |
| 163 | +        if ( $value instanceof \Closure ) { | 
                                                        |
| 164 | + $factory = $value;  | 
                                                        |
| 165 | + $value = $factory( $this );  | 
                                                        |
| 166 | + }  | 
                                                        |
| 167 | +  | 
                                                        |
| 168 | + // If the value is shared, save the shared value.  | 
                                                        |
| 169 | +        if ( isset( $this->shared[ $alias ] ) ) { | 
                                                        |
| 170 | + $this->definitions[ $alias ] = $value;  | 
                                                        |
| 171 | + }  | 
                                                        |
| 172 | +  | 
                                                        |
| 173 | + // Return the fetched value.  | 
                                                        |
| 174 | + return $value;  | 
                                                        |
| 175 | + }  | 
                                                        |
| 176 | +  | 
                                                        |
| 177 | + /**  | 
                                                        |
| 178 | +     * {@inheritdoc} | 
                                                        |
| 179 | + *  | 
                                                        |
| 180 | + * @param string $alias  | 
                                                        |
| 181 | + *  | 
                                                        |
| 182 | + * @return bool  | 
                                                        |
| 183 | + */  | 
                                                        |
| 184 | +    public function has( $alias ) { | 
                                                        |
| 185 | + return isset( $this->aliases[ $alias ] );  | 
                                                        |
| 186 | + }  | 
                                                        |
| 187 | +  | 
                                                        |
| 188 | + /**  | 
                                                        |
| 189 | +     * {@inheritDoc} | 
                                                        |
| 190 | + *  | 
                                                        |
| 191 | + * @param string $alias  | 
                                                        |
| 192 | + *  | 
                                                        |
| 193 | + * @return $this  | 
                                                        |
| 194 | + */  | 
                                                        |
| 195 | +    public function remove( $alias ) { | 
                                                        |
| 196 | +        if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 197 | + /**  | 
                                                        |
| 198 | + * If there's no reference in the aliases array,  | 
                                                        |
| 199 | + * the service won't be found on fetching and  | 
                                                        |
| 200 | + * can be overwritten on setting.  | 
                                                        |
| 201 | + *  | 
                                                        |
| 202 | + * Pros: Quick setting/unsetting, faster  | 
                                                        |
| 203 | + * performance on those operations when doing  | 
                                                        |
| 204 | + * a lot of these.  | 
                                                        |
| 205 | + *  | 
                                                        |
| 206 | + * Cons: Objects and values set in the container  | 
                                                        |
| 207 | + * can't get garbage collected.  | 
                                                        |
| 208 | + *  | 
                                                        |
| 209 | + * If this is a problem, this may need to be revisited.  | 
                                                        |
| 210 | + */  | 
                                                        |
| 211 | + unset( $this->aliases[ $alias ] );  | 
                                                        |
| 212 | + }  | 
                                                        |
| 213 | +  | 
                                                        |
| 214 | + return $this;  | 
                                                        |
| 215 | + }  | 
                                                        |
| 216 | +  | 
                                                        |
| 217 | + /**  | 
                                                        |
| 218 | +     * {@inheritDoc} | 
                                                        |
| 219 | + *  | 
                                                        |
| 220 | + * @param ServiceProvider $provider  | 
                                                        |
| 221 | + *  | 
                                                        |
| 222 | + * @return $this  | 
                                                        |
| 223 | + */  | 
                                                        |
| 224 | +    public function register( ServiceProvider $provider ) { | 
                                                        |
| 225 | + $provider->register( $this );  | 
                                                        |
| 226 | +  | 
                                                        |
| 227 | + return $this;  | 
                                                        |
| 228 | + }  | 
                                                        |
| 229 | +  | 
                                                        |
| 230 | + /**  | 
                                                        |
| 231 | + * Set a value into the container.  | 
                                                        |
| 232 | + *  | 
                                                        |
| 233 | + * @param string $id  | 
                                                        |
| 234 | + * @param mixed $value  | 
                                                        |
| 235 | + *  | 
                                                        |
| 236 | + * @see define  | 
                                                        |
| 237 | + */  | 
                                                        |
| 238 | +    public function offsetSet( $id, $value ) { | 
                                                        |
| 239 | + $this->define( $id, $value );  | 
                                                        |
| 240 | + }  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | + /**  | 
                                                        |
| 243 | + * Get an value from the container.  | 
                                                        |
| 244 | + *  | 
                                                        |
| 245 | + * @param string $id  | 
                                                        |
| 246 | + *  | 
                                                        |
| 247 | + * @return object  | 
                                                        |
| 248 | + * @throws UndefinedAliasException  | 
                                                        |
| 249 | + *  | 
                                                        |
| 250 | + * @see fetch  | 
                                                        |
| 251 | + */  | 
                                                        |
| 252 | +    public function offsetGet( $id ) { | 
                                                        |
| 253 | + return $this->fetch( $id );  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | +  | 
                                                        |
| 256 | + /**  | 
                                                        |
| 257 | + * Checks if a key is set on the container.  | 
                                                        |
| 258 | + *  | 
                                                        |
| 259 | + * @param string $id  | 
                                                        |
| 260 | + *  | 
                                                        |
| 261 | + * @return bool  | 
                                                        |
| 262 | + *  | 
                                                        |
| 263 | + * @see has  | 
                                                        |
| 264 | + */  | 
                                                        |
| 265 | +    public function offsetExists( $id ) { | 
                                                        |
| 266 | + return $this->has( $id );  | 
                                                        |
| 267 | + }  | 
                                                        |
| 268 | +  | 
                                                        |
| 269 | + /**  | 
                                                        |
| 270 | + * Remove a key from the container.  | 
                                                        |
| 271 | + *  | 
                                                        |
| 272 | + * @param string $id  | 
                                                        |
| 273 | + *  | 
                                                        |
| 274 | + * @see remove  | 
                                                        |
| 275 | + */  | 
                                                        |
| 276 | +    public function offsetUnset( $id ) { | 
                                                        |
| 277 | + $this->remove( $id );  | 
                                                        |
| 278 | + }  | 
                                                        |
| 279 | +  | 
                                                        |
| 280 | + /**  | 
                                                        |
| 281 | + * Sets the object properties to prepare for the loop.  | 
                                                        |
| 282 | + */  | 
                                                        |
| 283 | +    public function rewind() { | 
                                                        |
| 284 | + $this->position = 0;  | 
                                                        |
| 285 | + $this->keys = array_keys( $this->aliases );  | 
                                                        |
| 286 | + }  | 
                                                        |
| 287 | +  | 
                                                        |
| 288 | + /**  | 
                                                        |
| 289 | + * Retrieves the service object for the current step in the loop.  | 
                                                        |
| 290 | + *  | 
                                                        |
| 291 | + * @return object  | 
                                                        |
| 292 | + */  | 
                                                        |
| 293 | +    public function current() { | 
                                                        |
| 294 | + return $this->fetch( $this->keys[ $this->position ] );  | 
                                                        |
| 295 | + }  | 
                                                        |
| 296 | +  | 
                                                        |
| 297 | + /**  | 
                                                        |
| 298 | + * Retrieves the key for the current step in the loop.  | 
                                                        |
| 299 | + *  | 
                                                        |
| 300 | + * @return string  | 
                                                        |
| 301 | + */  | 
                                                        |
| 302 | +    public function key() { | 
                                                        |
| 303 | + return $this->keys[ $this->position ];  | 
                                                        |
| 304 | + }  | 
                                                        |
| 305 | +  | 
                                                        |
| 306 | + /**  | 
                                                        |
| 307 | + * Increments to the next step in the loop.  | 
                                                        |
| 308 | + */  | 
                                                        |
| 309 | +    public function next() { | 
                                                        |
| 310 | + $this->position ++;  | 
                                                        |
| 311 | + }  | 
                                                        |
| 312 | +  | 
                                                        |
| 313 | + /**  | 
                                                        |
| 314 | + * Checks if the next step in the loop in valid.  | 
                                                        |
| 315 | + *  | 
                                                        |
| 316 | + * @return bool  | 
                                                        |
| 317 | + */  | 
                                                        |
| 318 | +    public function valid() { | 
                                                        |
| 319 | + return isset( $this->keys[ $this->position ] );  | 
                                                        |
| 320 | + }  | 
                                                        |
| 321 | 321 | }  | 
                                                        
@@ -62,14 +62,14 @@ discard block  | 
                                                    ||
| 62 | 62 | *  | 
                                                        
| 63 | 63 | * @param ServiceProvider[]|string[] $providers  | 
                                                        
| 64 | 64 | */  | 
                                                        
| 65 | -	public function __construct( array $providers = array() ) { | 
                                                        |
| 66 | -		foreach ( $providers as $provider ) { | 
                                                        |
| 67 | -			if ( is_string( $provider ) && class_exists( $provider ) ) { | 
                                                        |
| 65 | +	public function __construct(array $providers = array()) { | 
                                                        |
| 66 | +		foreach ($providers as $provider) { | 
                                                        |
| 67 | +			if (is_string($provider) && class_exists($provider)) { | 
                                                        |
| 68 | 68 | $provider = new $provider;  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | -			if ( $provider instanceof ServiceProvider ) { | 
                                                        |
| 72 | - $this->register( $provider );  | 
                                                        |
| 71 | +			if ($provider instanceof ServiceProvider) { | 
                                                        |
| 72 | + $this->register($provider);  | 
                                                        |
| 73 | 73 | }  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | }  | 
                                                        
@@ -85,27 +85,27 @@ discard block  | 
                                                    ||
| 85 | 85 | *  | 
                                                        
| 86 | 86 | * @return $this  | 
                                                        
| 87 | 87 | */  | 
                                                        
| 88 | -	public function define( $alias, $definition ) { | 
                                                        |
| 89 | -		if ( is_array( $alias ) ) { | 
                                                        |
| 90 | - $class = current( $alias );  | 
                                                        |
| 91 | - $alias = key( $alias );  | 
                                                        |
| 88 | +	public function define($alias, $definition) { | 
                                                        |
| 89 | +		if (is_array($alias)) { | 
                                                        |
| 90 | + $class = current($alias);  | 
                                                        |
| 91 | + $alias = key($alias);  | 
                                                        |
| 92 | 92 | }  | 
                                                        
| 93 | 93 | |
| 94 | -		if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 94 | +		if (isset($this->aliases[$alias])) { | 
                                                        |
| 95 | 95 | throw new DefinedAliasException;  | 
                                                        
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
| 98 | - $this->aliases[ $alias ] = true;  | 
                                                        |
| 99 | - $this->definitions[ $alias ] = $definition;  | 
                                                        |
| 98 | + $this->aliases[$alias] = true;  | 
                                                        |
| 99 | + $this->definitions[$alias] = $definition;  | 
                                                        |
| 100 | 100 | |
| 101 | 101 | // Closures are treated as factories unless  | 
                                                        
| 102 | 102 | // defined via Container::share.  | 
                                                        
| 103 | -		if ( ! $definition instanceof \Closure ) { | 
                                                        |
| 104 | - $this->shared[ $alias ] = true;  | 
                                                        |
| 103 | +		if (!$definition instanceof \Closure) { | 
                                                        |
| 104 | + $this->shared[$alias] = true;  | 
                                                        |
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | -		if ( isset( $class ) ) { | 
                                                        |
| 108 | - $this->classes[ $class ] = $alias;  | 
                                                        |
| 107 | +		if (isset($class)) { | 
                                                        |
| 108 | + $this->classes[$class] = $alias;  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | return $this;  | 
                                                        
@@ -121,14 +121,14 @@ discard block  | 
                                                    ||
| 121 | 121 | *  | 
                                                        
| 122 | 122 | * @return $this  | 
                                                        
| 123 | 123 | */  | 
                                                        
| 124 | -	public function share( $alias, $definition ) { | 
                                                        |
| 125 | - $this->define( $alias, $definition );  | 
                                                        |
| 124 | +	public function share($alias, $definition) { | 
                                                        |
| 125 | + $this->define($alias, $definition);  | 
                                                        |
| 126 | 126 | |
| 127 | -		if ( is_array( $alias ) ) { | 
                                                        |
| 128 | - $alias = key( $alias );  | 
                                                        |
| 127 | +		if (is_array($alias)) { | 
                                                        |
| 128 | + $alias = key($alias);  | 
                                                        |
| 129 | 129 | }  | 
                                                        
| 130 | 130 | |
| 131 | - $this->shared[ $alias ] = true;  | 
                                                        |
| 131 | + $this->shared[$alias] = true;  | 
                                                        |
| 132 | 132 | |
| 133 | 133 | return $this;  | 
                                                        
| 134 | 134 | }  | 
                                                        
@@ -142,32 +142,32 @@ discard block  | 
                                                    ||
| 142 | 142 | *  | 
                                                        
| 143 | 143 | * @return mixed  | 
                                                        
| 144 | 144 | */  | 
                                                        
| 145 | -	public function fetch( $alias ) { | 
                                                        |
| 146 | -		if ( isset( $this->classes[ $alias ] ) ) { | 
                                                        |
| 145 | +	public function fetch($alias) { | 
                                                        |
| 146 | +		if (isset($this->classes[$alias])) { | 
                                                        |
| 147 | 147 | // If the alias is a class name,  | 
                                                        
| 148 | 148 | // then retrieve its linked alias.  | 
                                                        
| 149 | 149 | // This is only registered when  | 
                                                        
| 150 | 150 | // registering using an array.  | 
                                                        
| 151 | - $alias = $this->classes[ $alias ];  | 
                                                        |
| 151 | + $alias = $this->classes[$alias];  | 
                                                        |
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
| 154 | -		if ( ! isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 154 | +		if (!isset($this->aliases[$alias])) { | 
                                                        |
| 155 | 155 | throw new UndefinedAliasException;  | 
                                                        
| 156 | 156 | }  | 
                                                        
| 157 | 157 | |
| 158 | - $value = $this->definitions[ $alias ];  | 
                                                        |
| 158 | + $value = $this->definitions[$alias];  | 
                                                        |
| 159 | 159 | |
| 160 | 160 | // If the shared value is a closure,  | 
                                                        
| 161 | 161 | // execute it and assign the result  | 
                                                        
| 162 | 162 | // in place of the closure.  | 
                                                        
| 163 | -		if ( $value instanceof \Closure ) { | 
                                                        |
| 163 | +		if ($value instanceof \Closure) { | 
                                                        |
| 164 | 164 | $factory = $value;  | 
                                                        
| 165 | - $value = $factory( $this );  | 
                                                        |
| 165 | + $value = $factory($this);  | 
                                                        |
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | 168 | // If the value is shared, save the shared value.  | 
                                                        
| 169 | -		if ( isset( $this->shared[ $alias ] ) ) { | 
                                                        |
| 170 | - $this->definitions[ $alias ] = $value;  | 
                                                        |
| 169 | +		if (isset($this->shared[$alias])) { | 
                                                        |
| 170 | + $this->definitions[$alias] = $value;  | 
                                                        |
| 171 | 171 | }  | 
                                                        
| 172 | 172 | |
| 173 | 173 | // Return the fetched value.  | 
                                                        
@@ -181,8 +181,8 @@ discard block  | 
                                                    ||
| 181 | 181 | *  | 
                                                        
| 182 | 182 | * @return bool  | 
                                                        
| 183 | 183 | */  | 
                                                        
| 184 | -	public function has( $alias ) { | 
                                                        |
| 185 | - return isset( $this->aliases[ $alias ] );  | 
                                                        |
| 184 | +	public function has($alias) { | 
                                                        |
| 185 | + return isset($this->aliases[$alias]);  | 
                                                        |
| 186 | 186 | }  | 
                                                        
| 187 | 187 | |
| 188 | 188 | /**  | 
                                                        
@@ -192,8 +192,8 @@ discard block  | 
                                                    ||
| 192 | 192 | *  | 
                                                        
| 193 | 193 | * @return $this  | 
                                                        
| 194 | 194 | */  | 
                                                        
| 195 | -	public function remove( $alias ) { | 
                                                        |
| 196 | -		if ( isset( $this->aliases[ $alias ] ) ) { | 
                                                        |
| 195 | +	public function remove($alias) { | 
                                                        |
| 196 | +		if (isset($this->aliases[$alias])) { | 
                                                        |
| 197 | 197 | /**  | 
                                                        
| 198 | 198 | * If there's no reference in the aliases array,  | 
                                                        
| 199 | 199 | * the service won't be found on fetching and  | 
                                                        
@@ -208,7 +208,7 @@ discard block  | 
                                                    ||
| 208 | 208 | *  | 
                                                        
| 209 | 209 | * If this is a problem, this may need to be revisited.  | 
                                                        
| 210 | 210 | */  | 
                                                        
| 211 | - unset( $this->aliases[ $alias ] );  | 
                                                        |
| 211 | + unset($this->aliases[$alias]);  | 
                                                        |
| 212 | 212 | }  | 
                                                        
| 213 | 213 | |
| 214 | 214 | return $this;  | 
                                                        
@@ -221,8 +221,8 @@ discard block  | 
                                                    ||
| 221 | 221 | *  | 
                                                        
| 222 | 222 | * @return $this  | 
                                                        
| 223 | 223 | */  | 
                                                        
| 224 | -	public function register( ServiceProvider $provider ) { | 
                                                        |
| 225 | - $provider->register( $this );  | 
                                                        |
| 224 | +	public function register(ServiceProvider $provider) { | 
                                                        |
| 225 | + $provider->register($this);  | 
                                                        |
| 226 | 226 | |
| 227 | 227 | return $this;  | 
                                                        
| 228 | 228 | }  | 
                                                        
@@ -235,8 +235,8 @@ discard block  | 
                                                    ||
| 235 | 235 | *  | 
                                                        
| 236 | 236 | * @see define  | 
                                                        
| 237 | 237 | */  | 
                                                        
| 238 | -	public function offsetSet( $id, $value ) { | 
                                                        |
| 239 | - $this->define( $id, $value );  | 
                                                        |
| 238 | +	public function offsetSet($id, $value) { | 
                                                        |
| 239 | + $this->define($id, $value);  | 
                                                        |
| 240 | 240 | }  | 
                                                        
| 241 | 241 | |
| 242 | 242 | /**  | 
                                                        
@@ -249,8 +249,8 @@ discard block  | 
                                                    ||
| 249 | 249 | *  | 
                                                        
| 250 | 250 | * @see fetch  | 
                                                        
| 251 | 251 | */  | 
                                                        
| 252 | -	public function offsetGet( $id ) { | 
                                                        |
| 253 | - return $this->fetch( $id );  | 
                                                        |
| 252 | +	public function offsetGet($id) { | 
                                                        |
| 253 | + return $this->fetch($id);  | 
                                                        |
| 254 | 254 | }  | 
                                                        
| 255 | 255 | |
| 256 | 256 | /**  | 
                                                        
@@ -262,8 +262,8 @@ discard block  | 
                                                    ||
| 262 | 262 | *  | 
                                                        
| 263 | 263 | * @see has  | 
                                                        
| 264 | 264 | */  | 
                                                        
| 265 | -	public function offsetExists( $id ) { | 
                                                        |
| 266 | - return $this->has( $id );  | 
                                                        |
| 265 | +	public function offsetExists($id) { | 
                                                        |
| 266 | + return $this->has($id);  | 
                                                        |
| 267 | 267 | }  | 
                                                        
| 268 | 268 | |
| 269 | 269 | /**  | 
                                                        
@@ -273,8 +273,8 @@ discard block  | 
                                                    ||
| 273 | 273 | *  | 
                                                        
| 274 | 274 | * @see remove  | 
                                                        
| 275 | 275 | */  | 
                                                        
| 276 | -	public function offsetUnset( $id ) { | 
                                                        |
| 277 | - $this->remove( $id );  | 
                                                        |
| 276 | +	public function offsetUnset($id) { | 
                                                        |
| 277 | + $this->remove($id);  | 
                                                        |
| 278 | 278 | }  | 
                                                        
| 279 | 279 | |
| 280 | 280 | /**  | 
                                                        
@@ -282,7 +282,7 @@ discard block  | 
                                                    ||
| 282 | 282 | */  | 
                                                        
| 283 | 283 |  	public function rewind() { | 
                                                        
| 284 | 284 | $this->position = 0;  | 
                                                        
| 285 | - $this->keys = array_keys( $this->aliases );  | 
                                                        |
| 285 | + $this->keys = array_keys($this->aliases);  | 
                                                        |
| 286 | 286 | }  | 
                                                        
| 287 | 287 | |
| 288 | 288 | /**  | 
                                                        
@@ -291,7 +291,7 @@ discard block  | 
                                                    ||
| 291 | 291 | * @return object  | 
                                                        
| 292 | 292 | */  | 
                                                        
| 293 | 293 |  	public function current() { | 
                                                        
| 294 | - return $this->fetch( $this->keys[ $this->position ] );  | 
                                                        |
| 294 | + return $this->fetch($this->keys[$this->position]);  | 
                                                        |
| 295 | 295 | }  | 
                                                        
| 296 | 296 | |
| 297 | 297 | /**  | 
                                                        
@@ -300,14 +300,14 @@ discard block  | 
                                                    ||
| 300 | 300 | * @return string  | 
                                                        
| 301 | 301 | */  | 
                                                        
| 302 | 302 |  	public function key() { | 
                                                        
| 303 | - return $this->keys[ $this->position ];  | 
                                                        |
| 303 | + return $this->keys[$this->position];  | 
                                                        |
| 304 | 304 | }  | 
                                                        
| 305 | 305 | |
| 306 | 306 | /**  | 
                                                        
| 307 | 307 | * Increments to the next step in the loop.  | 
                                                        
| 308 | 308 | */  | 
                                                        
| 309 | 309 |  	public function next() { | 
                                                        
| 310 | - $this->position ++;  | 
                                                        |
| 310 | + $this->position++;  | 
                                                        |
| 311 | 311 | }  | 
                                                        
| 312 | 312 | |
| 313 | 313 | /**  | 
                                                        
@@ -316,6 +316,6 @@ discard block  | 
                                                    ||
| 316 | 316 | * @return bool  | 
                                                        
| 317 | 317 | */  | 
                                                        
| 318 | 318 |  	public function valid() { | 
                                                        
| 319 | - return isset( $this->keys[ $this->position ] );  | 
                                                        |
| 319 | + return isset($this->keys[$this->position]);  | 
                                                        |
| 320 | 320 | }  | 
                                                        
| 321 | 321 | }  | 
                                                        
@@ -18,80 +18,80 @@  | 
                                                    ||
| 18 | 18 | * @subpackage Model  | 
                                                        
| 19 | 19 | */  | 
                                                        
| 20 | 20 |  class Post extends Base { | 
                                                        
| 21 | - /**  | 
                                                        |
| 22 | - * Post type this model maps to.  | 
                                                        |
| 23 | - *  | 
                                                        |
| 24 | - * @var string  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - protected $type = 'post';  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | + * Post type this model maps to.  | 
                                                        |
| 23 | + *  | 
                                                        |
| 24 | + * @var string  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + protected $type = 'post';  | 
                                                        |
| 27 | 27 | |
| 28 | - /**  | 
                                                        |
| 29 | - * Fillable attributes for the model.  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @var array  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - protected $fillable = array( 'ID', 'author', 'slug', 'title', 'publish_date', 'content', 'excerpt' );  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * Fillable attributes for the model.  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @var array  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + protected $fillable = array( 'ID', 'author', 'slug', 'title', 'publish_date', 'content', 'excerpt' );  | 
                                                        |
| 34 | 34 | |
| 35 | - /**  | 
                                                        |
| 36 | - * ID property maps to ID.  | 
                                                        |
| 37 | - *  | 
                                                        |
| 38 | - * @return string  | 
                                                        |
| 39 | - */  | 
                                                        |
| 40 | -	protected function map_ID() { | 
                                                        |
| 41 | - return 'ID';  | 
                                                        |
| 42 | - }  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * ID property maps to ID.  | 
                                                        |
| 37 | + *  | 
                                                        |
| 38 | + * @return string  | 
                                                        |
| 39 | + */  | 
                                                        |
| 40 | +    protected function map_ID() { | 
                                                        |
| 41 | + return 'ID';  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | 43 | |
| 44 | - /**  | 
                                                        |
| 45 | - * Author property maps to post_author.  | 
                                                        |
| 46 | - *  | 
                                                        |
| 47 | - * @return string  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | -	protected function map_author() { | 
                                                        |
| 50 | - return 'post_author';  | 
                                                        |
| 51 | - }  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * Author property maps to post_author.  | 
                                                        |
| 46 | + *  | 
                                                        |
| 47 | + * @return string  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | +    protected function map_author() { | 
                                                        |
| 50 | + return 'post_author';  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | 52 | |
| 53 | - /**  | 
                                                        |
| 54 | - * Slug property maps to post_name.  | 
                                                        |
| 55 | - *  | 
                                                        |
| 56 | - * @return string  | 
                                                        |
| 57 | - */  | 
                                                        |
| 58 | -	protected function map_slug() { | 
                                                        |
| 59 | - return 'post_name';  | 
                                                        |
| 60 | - }  | 
                                                        |
| 53 | + /**  | 
                                                        |
| 54 | + * Slug property maps to post_name.  | 
                                                        |
| 55 | + *  | 
                                                        |
| 56 | + * @return string  | 
                                                        |
| 57 | + */  | 
                                                        |
| 58 | +    protected function map_slug() { | 
                                                        |
| 59 | + return 'post_name';  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | 61 | |
| 62 | - /**  | 
                                                        |
| 63 | - * Title property maps to post_title.  | 
                                                        |
| 64 | - *  | 
                                                        |
| 65 | - * @return string  | 
                                                        |
| 66 | - */  | 
                                                        |
| 67 | -	protected function map_title() { | 
                                                        |
| 68 | - return 'post_title';  | 
                                                        |
| 69 | - }  | 
                                                        |
| 62 | + /**  | 
                                                        |
| 63 | + * Title property maps to post_title.  | 
                                                        |
| 64 | + *  | 
                                                        |
| 65 | + * @return string  | 
                                                        |
| 66 | + */  | 
                                                        |
| 67 | +    protected function map_title() { | 
                                                        |
| 68 | + return 'post_title';  | 
                                                        |
| 69 | + }  | 
                                                        |
| 70 | 70 | |
| 71 | - /**  | 
                                                        |
| 72 | - * Publish date property maps to post_date_gmt.  | 
                                                        |
| 73 | - *  | 
                                                        |
| 74 | - * @return string  | 
                                                        |
| 75 | - */  | 
                                                        |
| 76 | -	protected function map_publish_date() { | 
                                                        |
| 77 | - return 'post_date_gmt';  | 
                                                        |
| 78 | - }  | 
                                                        |
| 71 | + /**  | 
                                                        |
| 72 | + * Publish date property maps to post_date_gmt.  | 
                                                        |
| 73 | + *  | 
                                                        |
| 74 | + * @return string  | 
                                                        |
| 75 | + */  | 
                                                        |
| 76 | +    protected function map_publish_date() { | 
                                                        |
| 77 | + return 'post_date_gmt';  | 
                                                        |
| 78 | + }  | 
                                                        |
| 79 | 79 | |
| 80 | - /**  | 
                                                        |
| 81 | - * Content property maps to post_content.  | 
                                                        |
| 82 | - *  | 
                                                        |
| 83 | - * @return string  | 
                                                        |
| 84 | - */  | 
                                                        |
| 85 | -	protected function map_content() { | 
                                                        |
| 86 | - return 'post_content';  | 
                                                        |
| 87 | - }  | 
                                                        |
| 80 | + /**  | 
                                                        |
| 81 | + * Content property maps to post_content.  | 
                                                        |
| 82 | + *  | 
                                                        |
| 83 | + * @return string  | 
                                                        |
| 84 | + */  | 
                                                        |
| 85 | +    protected function map_content() { | 
                                                        |
| 86 | + return 'post_content';  | 
                                                        |
| 87 | + }  | 
                                                        |
| 88 | 88 | |
| 89 | - /**¡  | 
                                                        |
| 89 | + /**¡  | 
                                                        |
| 90 | 90 | * Excerpt property maps to post_excerpt.  | 
                                                        
| 91 | 91 | *  | 
                                                        
| 92 | 92 | * @return string  | 
                                                        
| 93 | 93 | */  | 
                                                        
| 94 | -	protected function map_excerpt() { | 
                                                        |
| 95 | - return 'post_excerpt';  | 
                                                        |
| 96 | - }  | 
                                                        |
| 94 | +    protected function map_excerpt() { | 
                                                        |
| 95 | + return 'post_excerpt';  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | 97 | }  | 
                                                        
@@ -30,7 +30,7 @@  | 
                                                    ||
| 30 | 30 | *  | 
                                                        
| 31 | 31 | * @var array  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | - protected $fillable = array( 'ID', 'author', 'slug', 'title', 'publish_date', 'content', 'excerpt' );  | 
                                                        |
| 33 | +	protected $fillable = array('ID', 'author', 'slug', 'title', 'publish_date', 'content', 'excerpt'); | 
                                                        |
| 34 | 34 | |
| 35 | 35 | /**  | 
                                                        
| 36 | 36 | * ID property maps to ID.  | 
                                                        
@@ -2,13 +2,13 @@  | 
                                                    ||
| 2 | 2 | namespace Intraxia\Jaxion\Contract\Core;  | 
                                                        
| 3 | 3 | |
| 4 | 4 |  interface HasFilters { | 
                                                        
| 5 | - /**  | 
                                                        |
| 6 | - * Provides the array of filters the class wants to register with WordPress.  | 
                                                        |
| 7 | - *  | 
                                                        |
| 8 | - * These filters are retrieved by the Loader class and used to register the  | 
                                                        |
| 9 | - * correct service methods with WordPress.  | 
                                                        |
| 10 | - *  | 
                                                        |
| 11 | - * @return array[]  | 
                                                        |
| 12 | - */  | 
                                                        |
| 13 | - public function filter_hooks();  | 
                                                        |
| 5 | + /**  | 
                                                        |
| 6 | + * Provides the array of filters the class wants to register with WordPress.  | 
                                                        |
| 7 | + *  | 
                                                        |
| 8 | + * These filters are retrieved by the Loader class and used to register the  | 
                                                        |
| 9 | + * correct service methods with WordPress.  | 
                                                        |
| 10 | + *  | 
                                                        |
| 11 | + * @return array[]  | 
                                                        |
| 12 | + */  | 
                                                        |
| 13 | + public function filter_hooks();  | 
                                                        |
| 14 | 14 | }  | 
                                                        
| 15 | 15 | \ No newline at end of file  | 
                                                        
@@ -4,64 +4,64 @@  | 
                                                    ||
| 4 | 4 | use Intraxia\Jaxion\Core\ApplicationNotBootedException;  | 
                                                        
| 5 | 5 | |
| 6 | 6 |  interface Application { | 
                                                        
| 7 | - /**  | 
                                                        |
| 8 | - * Instantiates a new Application container.  | 
                                                        |
| 9 | - *  | 
                                                        |
| 10 | - * The Application constructor enforces the presence of of a single instance  | 
                                                        |
| 11 | - * of the Application. If an instance already exists, an Exception will be thrown.  | 
                                                        |
| 12 | - *  | 
                                                        |
| 13 | - * @param string $file  | 
                                                        |
| 14 | - *  | 
                                                        |
| 15 | - * @throws \Intraxia\Jaxion\Core\ApplicationAlreadyBootedException  | 
                                                        |
| 16 | - */  | 
                                                        |
| 17 | - public function __construct( $file );  | 
                                                        |
| 7 | + /**  | 
                                                        |
| 8 | + * Instantiates a new Application container.  | 
                                                        |
| 9 | + *  | 
                                                        |
| 10 | + * The Application constructor enforces the presence of of a single instance  | 
                                                        |
| 11 | + * of the Application. If an instance already exists, an Exception will be thrown.  | 
                                                        |
| 12 | + *  | 
                                                        |
| 13 | + * @param string $file  | 
                                                        |
| 14 | + *  | 
                                                        |
| 15 | + * @throws \Intraxia\Jaxion\Core\ApplicationAlreadyBootedException  | 
                                                        |
| 16 | + */  | 
                                                        |
| 17 | + public function __construct( $file );  | 
                                                        |
| 18 | 18 | |
| 19 | - /**  | 
                                                        |
| 20 | - * Starts up the Application.  | 
                                                        |
| 21 | - *  | 
                                                        |
| 22 | - * Retrieves the Application's loader instance, and registers all of the Application's  | 
                                                        |
| 23 | - * services with the loader. It loops through its own services, and any services that  | 
                                                        |
| 24 | - * implement the required interface are passed into the loader. It then attaches the  | 
                                                        |
| 25 | - * loader to the required WordPress hook.  | 
                                                        |
| 26 | - */  | 
                                                        |
| 27 | - public function boot();  | 
                                                        |
| 19 | + /**  | 
                                                        |
| 20 | + * Starts up the Application.  | 
                                                        |
| 21 | + *  | 
                                                        |
| 22 | + * Retrieves the Application's loader instance, and registers all of the Application's  | 
                                                        |
| 23 | + * services with the loader. It loops through its own services, and any services that  | 
                                                        |
| 24 | + * implement the required interface are passed into the loader. It then attaches the  | 
                                                        |
| 25 | + * loader to the required WordPress hook.  | 
                                                        |
| 26 | + */  | 
                                                        |
| 27 | + public function boot();  | 
                                                        |
| 28 | 28 | |
| 29 | - /**  | 
                                                        |
| 30 | - * Fired on plugin activation.  | 
                                                        |
| 31 | - *  | 
                                                        |
| 32 | - * This function is attached to `register_activation_hook` and is fired when the plugin is  | 
                                                        |
| 33 | - * activated by WordPress. This gives the developer a place to set up any options,  | 
                                                        |
| 34 | - * add any custom tables, or flush rewrite rules, as required.  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - public function activate();  | 
                                                        |
| 29 | + /**  | 
                                                        |
| 30 | + * Fired on plugin activation.  | 
                                                        |
| 31 | + *  | 
                                                        |
| 32 | + * This function is attached to `register_activation_hook` and is fired when the plugin is  | 
                                                        |
| 33 | + * activated by WordPress. This gives the developer a place to set up any options,  | 
                                                        |
| 34 | + * add any custom tables, or flush rewrite rules, as required.  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + public function activate();  | 
                                                        |
| 37 | 37 | |
| 38 | - /**  | 
                                                        |
| 39 | - * Fired on plugin deactivation.  | 
                                                        |
| 40 | - *  | 
                                                        |
| 41 | - * This function is attached to `register_deactivation_hook` and is fired when the plugin  | 
                                                        |
| 42 | - * is deactivated by WordPress. This gives the developer a place to clean up anything left  | 
                                                        |
| 43 | - * behind by the plugin.  | 
                                                        |
| 44 | - */  | 
                                                        |
| 45 | - public function deactivate();  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * Fired on plugin deactivation.  | 
                                                        |
| 40 | + *  | 
                                                        |
| 41 | + * This function is attached to `register_deactivation_hook` and is fired when the plugin  | 
                                                        |
| 42 | + * is deactivated by WordPress. This gives the developer a place to clean up anything left  | 
                                                        |
| 43 | + * behind by the plugin.  | 
                                                        |
| 44 | + */  | 
                                                        |
| 45 | + public function deactivate();  | 
                                                        |
| 46 | 46 | |
| 47 | - /**  | 
                                                        |
| 48 | - * Retrieves the booted Application instance.  | 
                                                        |
| 49 | - *  | 
                                                        |
| 50 | - * If the Application has not yet been booted, an Exception will be thrown.  | 
                                                        |
| 51 | - *  | 
                                                        |
| 52 | - * @return Application  | 
                                                        |
| 53 | - * @throws ApplicationNotBootedException  | 
                                                        |
| 54 | - */  | 
                                                        |
| 55 | - public static function instance();  | 
                                                        |
| 47 | + /**  | 
                                                        |
| 48 | + * Retrieves the booted Application instance.  | 
                                                        |
| 49 | + *  | 
                                                        |
| 50 | + * If the Application has not yet been booted, an Exception will be thrown.  | 
                                                        |
| 51 | + *  | 
                                                        |
| 52 | + * @return Application  | 
                                                        |
| 53 | + * @throws ApplicationNotBootedException  | 
                                                        |
| 54 | + */  | 
                                                        |
| 55 | + public static function instance();  | 
                                                        |
| 56 | 56 | |
| 57 | - /**  | 
                                                        |
| 58 | - * Shuts down the booted Application.  | 
                                                        |
| 59 | - *  | 
                                                        |
| 60 | - * If the Application has already been booted, the Application instance  | 
                                                        |
| 61 | - * will be destroyed by assigning it a null value, freeing it from memory.  | 
                                                        |
| 62 | - * However, the service objects will likely remain in memory if they've been  | 
                                                        |
| 63 | - * attached to hooks when this method is called. This function is primarily  | 
                                                        |
| 64 | - * for uniting testing to make sure you can boot a new instance for each test.  | 
                                                        |
| 65 | - */  | 
                                                        |
| 66 | - public static function shutdown();  | 
                                                        |
| 57 | + /**  | 
                                                        |
| 58 | + * Shuts down the booted Application.  | 
                                                        |
| 59 | + *  | 
                                                        |
| 60 | + * If the Application has already been booted, the Application instance  | 
                                                        |
| 61 | + * will be destroyed by assigning it a null value, freeing it from memory.  | 
                                                        |
| 62 | + * However, the service objects will likely remain in memory if they've been  | 
                                                        |
| 63 | + * attached to hooks when this method is called. This function is primarily  | 
                                                        |
| 64 | + * for uniting testing to make sure you can boot a new instance for each test.  | 
                                                        |
| 65 | + */  | 
                                                        |
| 66 | + public static function shutdown();  | 
                                                        |
| 67 | 67 | }  | 
                                                        
@@ -14,7 +14,7 @@  | 
                                                    ||
| 14 | 14 | *  | 
                                                        
| 15 | 15 | * @throws \Intraxia\Jaxion\Core\ApplicationAlreadyBootedException  | 
                                                        
| 16 | 16 | */  | 
                                                        
| 17 | - public function __construct( $file );  | 
                                                        |
| 17 | + public function __construct($file);  | 
                                                        |
| 18 | 18 | |
| 19 | 19 | /**  | 
                                                        
| 20 | 20 | * Starts up the Application.  | 
                                                        
@@ -2,13 +2,13 @@  | 
                                                    ||
| 2 | 2 | namespace Intraxia\Jaxion\Contract\Core;  | 
                                                        
| 3 | 3 | |
| 4 | 4 |  interface ServiceProvider { | 
                                                        
| 5 | - /**  | 
                                                        |
| 6 | - * Register the provider's services on the container.  | 
                                                        |
| 7 | - *  | 
                                                        |
| 8 | - * This method is passed the container to register on, giving the service provider  | 
                                                        |
| 9 | - * an opportunity to register its services on the container in an encapsulated way.  | 
                                                        |
| 10 | - *  | 
                                                        |
| 11 | - * @param Container $container  | 
                                                        |
| 12 | - */  | 
                                                        |
| 13 | - public function register( Container $container );  | 
                                                        |
| 5 | + /**  | 
                                                        |
| 6 | + * Register the provider's services on the container.  | 
                                                        |
| 7 | + *  | 
                                                        |
| 8 | + * This method is passed the container to register on, giving the service provider  | 
                                                        |
| 9 | + * an opportunity to register its services on the container in an encapsulated way.  | 
                                                        |
| 10 | + *  | 
                                                        |
| 11 | + * @param Container $container  | 
                                                        |
| 12 | + */  | 
                                                        |
| 13 | + public function register( Container $container );  | 
                                                        |
| 14 | 14 | }  | 
                                                        
| 15 | 15 | \ No newline at end of file  | 
                                                        
@@ -10,5 +10,5 @@  | 
                                                    ||
| 10 | 10 | *  | 
                                                        
| 11 | 11 | * @param Container $container  | 
                                                        
| 12 | 12 | */  | 
                                                        
| 13 | - public function register( Container $container );  | 
                                                        |
| 13 | + public function register(Container $container);  | 
                                                        |
| 14 | 14 | }  | 
                                                        
| 15 | 15 | \ No newline at end of file  |