@@ -11,9 +11,9 @@  | 
                                                    ||
| 11 | 11 | |
| 12 | 12 | namespace BrightNucleus\Shortcode;  | 
                                                        
| 13 | 13 | |
| 14 | -use BrightNucleus\Config\ConfigInterface;  | 
                                                        |
| 15 | -use BrightNucleus\Config\ConfigTrait;  | 
                                                        |
| 16 | -use BrightNucleus\Dependency\DependencyManagerInterface;  | 
                                                        |
| 14 | +use BrightNucleus\Config\ConfigInterface;  | 
                                                        |
| 15 | +use BrightNucleus\Config\ConfigTrait;  | 
                                                        |
| 16 | +use BrightNucleus\Dependency\DependencyManagerInterface;  | 
                                                        |
| 17 | 17 | use BrightNucleus\Exception\RuntimeException;  | 
                                                        
| 18 | 18 | |
| 19 | 19 | /**  | 
                                                        
@@ -39,9 +39,9 @@ discard block  | 
                                                    ||
| 39 | 39 | /*  | 
                                                        
| 40 | 40 | * Default classes that are used when omitted from the config.  | 
                                                        
| 41 | 41 | */  | 
                                                        
| 42 | - const DEFAULT_SHORTCODE = __NAMESPACE__ . '\Shortcode';  | 
                                                        |
| 43 | - const DEFAULT_SHORTCODE_ATTS_PARSER = __NAMESPACE__ . '\ShortcodeAttsParser';  | 
                                                        |
| 44 | - const DEFAULT_SHORTCODE_UI = __NAMESPACE__ . '\ShortcodeUI';  | 
                                                        |
| 42 | + const DEFAULT_SHORTCODE = __NAMESPACE__.'\Shortcode';  | 
                                                        |
| 43 | + const DEFAULT_SHORTCODE_ATTS_PARSER = __NAMESPACE__.'\ShortcodeAttsParser';  | 
                                                        |
| 44 | + const DEFAULT_SHORTCODE_UI = __NAMESPACE__.'\ShortcodeUI';  | 
                                                        |
| 45 | 45 | |
| 46 | 46 | /*  | 
                                                        
| 47 | 47 | * The names of the configuration keys.  | 
                                                        
@@ -58,7 +58,7 @@ discard block  | 
                                                    ||
| 58 | 58 | *  | 
                                                        
| 59 | 59 | * @var ShortcodeInterface[]  | 
                                                        
| 60 | 60 | */  | 
                                                        
| 61 | - protected $shortcodes = [ ];  | 
                                                        |
| 61 | + protected $shortcodes = [];  | 
                                                        |
| 62 | 62 | |
| 63 | 63 | /**  | 
                                                        
| 64 | 64 | * DependencyManagerInterface implementation.  | 
                                                        
@@ -76,7 +76,7 @@ discard block  | 
                                                    ||
| 76 | 76 | *  | 
                                                        
| 77 | 77 | * @var ShortcodeUIInterface[]  | 
                                                        
| 78 | 78 | */  | 
                                                        
| 79 | - protected $shortcode_uis = [ ];  | 
                                                        |
| 79 | + protected $shortcode_uis = [];  | 
                                                        |
| 80 | 80 | |
| 81 | 81 | /**  | 
                                                        
| 82 | 82 | * Instantiate a ShortcodeManager object.  | 
                                                        
@@ -94,9 +94,9 @@ discard block  | 
                                                    ||
| 94 | 94 | ConfigInterface $config,  | 
                                                        
| 95 | 95 | DependencyManagerInterface $dependencies  | 
                                                        
| 96 | 96 |  	) {
 | 
                                                        
| 97 | - $this->processConfig( $config );  | 
                                                        |
| 97 | + $this->processConfig($config);  | 
                                                        |
| 98 | 98 | |
| 99 | -		if ( ! $this->hasConfigKey( self::KEY_TAGS ) ) {
 | 
                                                        |
| 99 | +		if ( ! $this->hasConfigKey(self::KEY_TAGS)) {
 | 
                                                        |
| 100 | 100 | return;  | 
                                                        
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
@@ -112,8 +112,8 @@ discard block  | 
                                                    ||
| 112 | 112 | */  | 
                                                        
| 113 | 113 |  	public function init_shortcodes() {
 | 
                                                        
| 114 | 114 | |
| 115 | -		foreach ( $this->getConfigKey( self::KEY_TAGS ) as $tag => $config ) {
 | 
                                                        |
| 116 | - $this->init_shortcode( $tag );  | 
                                                        |
| 115 | +		foreach ($this->getConfigKey(self::KEY_TAGS) as $tag => $config) {
 | 
                                                        |
| 116 | + $this->init_shortcode($tag);  | 
                                                        |
| 117 | 117 | }  | 
                                                        
| 118 | 118 | }  | 
                                                        
| 119 | 119 | |
@@ -124,12 +124,12 @@ discard block  | 
                                                    ||
| 124 | 124 | *  | 
                                                        
| 125 | 125 | * @param string $tag The tag of the shortcode to register.  | 
                                                        
| 126 | 126 | */  | 
                                                        
| 127 | -	protected function init_shortcode( $tag ) {
 | 
                                                        |
| 128 | - $shortcode_class = $this->get_shortcode_class( $tag );  | 
                                                        |
| 129 | - $shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );  | 
                                                        |
| 127 | +	protected function init_shortcode($tag) {
 | 
                                                        |
| 128 | + $shortcode_class = $this->get_shortcode_class($tag);  | 
                                                        |
| 129 | + $shortcode_atts_parser = $this->get_shortcode_atts_parser_class($tag);  | 
                                                        |
| 130 | 130 | |
| 131 | 131 | $atts_parser = new $shortcode_atts_parser(  | 
                                                        
| 132 | - $this->config->getSubConfig( self::KEY_TAGS, $tag )  | 
                                                        |
| 132 | + $this->config->getSubConfig(self::KEY_TAGS, $tag)  | 
                                                        |
| 133 | 133 | );  | 
                                                        
| 134 | 134 | |
| 135 | 135 | $this->shortcodes[] = new $shortcode_class(  | 
                                                        
@@ -139,8 +139,8 @@ discard block  | 
                                                    ||
| 139 | 139 | $this->dependencies  | 
                                                        
| 140 | 140 | );  | 
                                                        
| 141 | 141 | |
| 142 | -		if ( $this->hasConfigKey( self::KEY_TAGS, $tag, self::KEY_UI ) ) {
 | 
                                                        |
| 143 | - $this->init_shortcode_ui( $tag );  | 
                                                        |
| 142 | +		if ($this->hasConfigKey(self::KEY_TAGS, $tag, self::KEY_UI)) {
 | 
                                                        |
| 143 | + $this->init_shortcode_ui($tag);  | 
                                                        |
| 144 | 144 | }  | 
                                                        
| 145 | 145 | }  | 
                                                        
| 146 | 146 | |
@@ -152,10 +152,10 @@ discard block  | 
                                                    ||
| 152 | 152 | * @param string $tag Shortcode tag to get the class for.  | 
                                                        
| 153 | 153 | * @return string Class name of the Shortcode.  | 
                                                        
| 154 | 154 | */  | 
                                                        
| 155 | -	protected function get_shortcode_class( $tag ) {
 | 
                                                        |
| 156 | - $key = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_CLASS ];  | 
                                                        |
| 157 | - $shortcode_class = $this->hasConfigKey( $key )  | 
                                                        |
| 158 | - ? $this->getConfigKey( $key )  | 
                                                        |
| 155 | +	protected function get_shortcode_class($tag) {
 | 
                                                        |
| 156 | + $key = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_CLASS];  | 
                                                        |
| 157 | + $shortcode_class = $this->hasConfigKey($key)  | 
                                                        |
| 158 | + ? $this->getConfigKey($key)  | 
                                                        |
| 159 | 159 | : self::DEFAULT_SHORTCODE;  | 
                                                        
| 160 | 160 | return $shortcode_class;  | 
                                                        
| 161 | 161 | }  | 
                                                        
@@ -169,10 +169,10 @@ discard block  | 
                                                    ||
| 169 | 169 | * @param string $tag Shortcode tag to get the class for.  | 
                                                        
| 170 | 170 | * @return string Class name of the ShortcodeAttsParser.  | 
                                                        
| 171 | 171 | */  | 
                                                        
| 172 | -	protected function get_shortcode_atts_parser_class( $tag ) {
 | 
                                                        |
| 173 | - $key = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_ATTS_PARSER ];  | 
                                                        |
| 174 | - $atts_parser = $this->hasConfigKey( $key )  | 
                                                        |
| 175 | - ? $this->getConfigKey( $key )  | 
                                                        |
| 172 | +	protected function get_shortcode_atts_parser_class($tag) {
 | 
                                                        |
| 173 | + $key = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_ATTS_PARSER];  | 
                                                        |
| 174 | + $atts_parser = $this->hasConfigKey($key)  | 
                                                        |
| 175 | + ? $this->getConfigKey($key)  | 
                                                        |
| 176 | 176 | : self::DEFAULT_SHORTCODE_ATTS_PARSER;  | 
                                                        
| 177 | 177 | return $atts_parser;  | 
                                                        
| 178 | 178 | }  | 
                                                        
@@ -184,8 +184,8 @@ discard block  | 
                                                    ||
| 184 | 184 | *  | 
                                                        
| 185 | 185 | * @param string $tag The tag of the shortcode to register the UI for.  | 
                                                        
| 186 | 186 | */  | 
                                                        
| 187 | -	protected function init_shortcode_ui( $tag ) {
 | 
                                                        |
| 188 | - $shortcode_ui_class = $this->get_shortcode_ui_class( $tag );  | 
                                                        |
| 187 | +	protected function init_shortcode_ui($tag) {
 | 
                                                        |
| 188 | + $shortcode_ui_class = $this->get_shortcode_ui_class($tag);  | 
                                                        |
| 189 | 189 | |
| 190 | 190 | $this->shortcode_uis[] = new $shortcode_ui_class(  | 
                                                        
| 191 | 191 | $tag,  | 
                                                        
@@ -202,10 +202,10 @@ discard block  | 
                                                    ||
| 202 | 202 | * @param string $tag Configuration settings.  | 
                                                        
| 203 | 203 | * @return string Class name of the ShortcodeUI.  | 
                                                        
| 204 | 204 | */  | 
                                                        
| 205 | -	protected function get_shortcode_ui_class( $tag ) {
 | 
                                                        |
| 206 | - $key = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_UI ];  | 
                                                        |
| 207 | - $ui_class = $this->hasConfigKey( $key )  | 
                                                        |
| 208 | - ? $this->getConfigKey( $key )  | 
                                                        |
| 205 | +	protected function get_shortcode_ui_class($tag) {
 | 
                                                        |
| 206 | + $key = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_UI];  | 
                                                        |
| 207 | + $ui_class = $this->hasConfigKey($key)  | 
                                                        |
| 208 | + ? $this->getConfigKey($key)  | 
                                                        |
| 209 | 209 | : self::DEFAULT_SHORTCODE_UI;  | 
                                                        
| 210 | 210 | return $ui_class;  | 
                                                        
| 211 | 211 | }  | 
                                                        
@@ -218,7 +218,7 @@ discard block  | 
                                                    ||
| 218 | 218 | * @return void  | 
                                                        
| 219 | 219 | */  | 
                                                        
| 220 | 220 |  	public function register() {
 | 
                                                        
| 221 | -		array_walk( $this->shortcodes, function ( $shortcode ) {
 | 
                                                        |
| 221 | +		array_walk($this->shortcodes, function($shortcode) {
 | 
                                                        |
| 222 | 222 | /** @var ShortcodeInterface $shortcode */  | 
                                                        
| 223 | 223 | $shortcode->register();  | 
                                                        
| 224 | 224 | } );  | 
                                                        
@@ -226,7 +226,7 @@ discard block  | 
                                                    ||
| 226 | 226 | // This hook only gets fired when Shortcode UI plugin is active.  | 
                                                        
| 227 | 227 | \add_action(  | 
                                                        
| 228 | 228 | 'register_shortcode_ui',  | 
                                                        
| 229 | - [ $this, 'register_shortcode_ui', ]  | 
                                                        |
| 229 | + [$this, 'register_shortcode_ui', ]  | 
                                                        |
| 230 | 230 | );  | 
                                                        
| 231 | 231 | }  | 
                                                        
| 232 | 232 | |
@@ -237,12 +237,12 @@ discard block  | 
                                                    ||
| 237 | 237 | */  | 
                                                        
| 238 | 238 |  	public function register_shortcode_ui() {
 | 
                                                        
| 239 | 239 | $template = $this->get_page_template();  | 
                                                        
| 240 | - $context = [ 'page_template' => $template ];  | 
                                                        |
| 240 | + $context = ['page_template' => $template];  | 
                                                        |
| 241 | 241 | |
| 242 | - array_walk( $this->shortcode_uis,  | 
                                                        |
| 243 | -			function ( $shortcode_ui ) use ( $context ) {
 | 
                                                        |
| 242 | + array_walk($this->shortcode_uis,  | 
                                                        |
| 243 | +			function($shortcode_ui) use ($context) {
 | 
                                                        |
| 244 | 244 | /** @var ShortcodeUIInterface $shortcode_ui */  | 
                                                        
| 245 | - $shortcode_ui->register( $context );  | 
                                                        |
| 245 | + $shortcode_ui->register($context);  | 
                                                        |
| 246 | 246 | }  | 
                                                        
| 247 | 247 | );  | 
                                                        
| 248 | 248 | }  | 
                                                        
@@ -256,7 +256,7 @@ discard block  | 
                                                    ||
| 256 | 256 | */  | 
                                                        
| 257 | 257 |  	protected function get_page_template() {
 | 
                                                        
| 258 | 258 | $template = str_replace(  | 
                                                        
| 259 | - \trailingslashit( \get_stylesheet_directory() ),  | 
                                                        |
| 259 | + \trailingslashit(\get_stylesheet_directory()),  | 
                                                        |
| 260 | 260 | '',  | 
                                                        
| 261 | 261 | \get_page_template()  | 
                                                        
| 262 | 262 | );  | 
                                                        
@@ -82,9 +82,9 @@ discard block  | 
                                                    ||
| 82 | 82 | DependencyManagerInterface $dependencies  | 
                                                        
| 83 | 83 |  	) {
 | 
                                                        
| 84 | 84 | |
| 85 | - Assert\that( $shortcode_tag )->string()->notEmpty();  | 
                                                        |
| 85 | + Assert\that($shortcode_tag)->string()->notEmpty();  | 
                                                        |
| 86 | 86 | |
| 87 | - $this->processConfig( $config );  | 
                                                        |
| 87 | + $this->processConfig($config);  | 
                                                        |
| 88 | 88 | |
| 89 | 89 | $this->shortcode_tag = $shortcode_tag;  | 
                                                        
| 90 | 90 | $this->atts_parser = $atts_parser;  | 
                                                        
@@ -100,8 +100,8 @@ discard block  | 
                                                    ||
| 100 | 100 | * (Not used with Shortcode class)  | 
                                                        
| 101 | 101 | * @return void  | 
                                                        
| 102 | 102 | */  | 
                                                        
| 103 | -	public function register( $args = null ) {
 | 
                                                        |
| 104 | - \add_shortcode( $this->get_tag(), [ $this, 'render' ] );  | 
                                                        |
| 103 | +	public function register($args = null) {
 | 
                                                        |
| 104 | + \add_shortcode($this->get_tag(), [$this, 'render']);  | 
                                                        |
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | 107 | /**  | 
                                                        
@@ -127,20 +127,20 @@ discard block  | 
                                                    ||
| 127 | 127 | * @param string|null $content Content between enclosing shortcodes.  | 
                                                        
| 128 | 128 | * @return string The shortcode's HTML output.  | 
                                                        
| 129 | 129 | */  | 
                                                        
| 130 | -	public function render( $atts, $content = null ) {
 | 
                                                        |
| 131 | - $atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() );  | 
                                                        |
| 130 | +	public function render($atts, $content = null) {
 | 
                                                        |
| 131 | + $atts = $this->atts_parser->parse_atts($atts, $this->get_tag());  | 
                                                        |
| 132 | 132 | |
| 133 | - $this->dependencies->enqueue( $atts );  | 
                                                        |
| 133 | + $this->dependencies->enqueue($atts);  | 
                                                        |
| 134 | 134 | |
| 135 | -		if ( ! $this->hasConfigKey( 'view' ) ) {
 | 
                                                        |
| 135 | +		if ( ! $this->hasConfigKey('view')) {
 | 
                                                        |
| 136 | 136 | return '';  | 
                                                        
| 137 | 137 | }  | 
                                                        
| 138 | - $view = $this->getConfigKey( 'view' );  | 
                                                        |
| 138 | +		$view = $this->getConfigKey('view');
 | 
                                                        |
| 139 | 139 | |
| 140 | - Assert\that( $view )->string()->notEmpty()->file();  | 
                                                        |
| 140 | + Assert\that($view)->string()->notEmpty()->file();  | 
                                                        |
| 141 | 141 | |
| 142 | 142 | ob_start();  | 
                                                        
| 143 | - include( $this->config['view'] );  | 
                                                        |
| 143 | + include($this->config['view']);  | 
                                                        |
| 144 | 144 | |
| 145 | 145 | return ob_get_clean();  | 
                                                        
| 146 | 146 | }  | 
                                                        
@@ -37,8 +37,8 @@ discard block  | 
                                                    ||
| 37 | 37 | * attributes.  | 
                                                        
| 38 | 38 | * @throws RuntimeException If the config could not be processed.  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | -	public function __construct( ConfigInterface $config ) { | 
                                                        |
| 41 | - $this->processConfig( $config );  | 
                                                        |
| 40 | +	public function __construct(ConfigInterface $config) { | 
                                                        |
| 41 | + $this->processConfig($config);  | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | 44 | /**  | 
                                                        
@@ -50,10 +50,10 @@ discard block  | 
                                                    ||
| 50 | 50 | * @param string $tag Tag of the shortcode.  | 
                                                        
| 51 | 51 | * @return array Validated attributes of the shortcode.  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | -	public function parse_atts( $atts, $tag ) { | 
                                                        |
| 53 | +	public function parse_atts($atts, $tag) { | 
                                                        |
| 54 | 54 | $atts = \shortcode_atts(  | 
                                                        
| 55 | 55 | $this->default_atts(),  | 
                                                        
| 56 | - $this->validated_atts( $atts ),  | 
                                                        |
| 56 | + $this->validated_atts($atts),  | 
                                                        |
| 57 | 57 | $tag  | 
                                                        
| 58 | 58 | );  | 
                                                        
| 59 | 59 | |
@@ -71,13 +71,13 @@ discard block  | 
                                                    ||
| 71 | 71 | |
| 72 | 72 | $atts = array();  | 
                                                        
| 73 | 73 | |
| 74 | -		if ( ! $this->hasConfigKey( 'atts' ) ) { | 
                                                        |
| 74 | +		if ( ! $this->hasConfigKey('atts')) { | 
                                                        |
| 75 | 75 | return $atts;  | 
                                                        
| 76 | 76 | }  | 
                                                        
| 77 | 77 | |
| 78 | - array_walk( $this->getConfigKey( 'atts' ),  | 
                                                        |
| 79 | -			function ( $att_properties, $att_label ) use ( &$atts ) { | 
                                                        |
| 80 | - $atts[ $att_label ] = $att_properties['default'];  | 
                                                        |
| 78 | +		array_walk($this->getConfigKey('atts'), | 
                                                        |
| 79 | +			function($att_properties, $att_label) use (&$atts) { | 
                                                        |
| 80 | + $atts[$att_label] = $att_properties['default'];  | 
                                                        |
| 81 | 81 | }  | 
                                                        
| 82 | 82 | );  | 
                                                        
| 83 | 83 | |
@@ -93,17 +93,17 @@ discard block  | 
                                                    ||
| 93 | 93 | * @param array $atts Attributes that were passed to the shortcode.  | 
                                                        
| 94 | 94 | * @return array Validated attributes.  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | -	protected function validated_atts( $atts ) { | 
                                                        |
| 96 | +	protected function validated_atts($atts) { | 
                                                        |
| 97 | 97 | |
| 98 | -		if ( ! $this->hasConfigKey( 'atts' ) ) { | 
                                                        |
| 98 | +		if ( ! $this->hasConfigKey('atts')) { | 
                                                        |
| 99 | 99 | return $atts;  | 
                                                        
| 100 | 100 | }  | 
                                                        
| 101 | 101 | |
| 102 | - array_walk( $this->getConfigKey( 'atts' ),  | 
                                                        |
| 103 | -			function ( $att_properties, $att_label ) use ( &$atts ) { | 
                                                        |
| 104 | -				if ( array_key_exists( $att_label, $atts ) ) { | 
                                                        |
| 102 | +		array_walk($this->getConfigKey('atts'), | 
                                                        |
| 103 | +			function($att_properties, $att_label) use (&$atts) { | 
                                                        |
| 104 | +				if (array_key_exists($att_label, $atts)) { | 
                                                        |
| 105 | 105 | $validate_function = $att_properties['validate'];  | 
                                                        
| 106 | - $atts[ $att_label ] = $validate_function( $atts[ $att_label ] );  | 
                                                        |
| 106 | + $atts[$att_label] = $validate_function($atts[$att_label]);  | 
                                                        |
| 107 | 107 | }  | 
                                                        
| 108 | 108 | }  | 
                                                        
| 109 | 109 | );  | 
                                                        
@@ -30,5 +30,5 @@  | 
                                                    ||
| 30 | 30 | * @param string $tag Tag of the shortcode.  | 
                                                        
| 31 | 31 | * @return array Validated attributes of the shortcode.  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | - public function parse_atts( $atts, $tag );  | 
                                                        |
| 33 | + public function parse_atts($atts, $tag);  | 
                                                        |
| 34 | 34 | }  |