Passed
Push — master ( 534b30...4b0b81 )
by Alain
07:20
created
src/Shortcode.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 		$config_key = null
86 86
 	) {
87 87
 
88
-		Assert\that( $shortcode_tag )->string()->notEmpty();
88
+		Assert\that($shortcode_tag)->string()->notEmpty();
89 89
 
90
-		$this->processConfig( $config, $config_key );
90
+		$this->processConfig($config, $config_key);
91 91
 
92 92
 		$this->shortcode_tag = $shortcode_tag;
93 93
 		$this->atts_parser   = $atts_parser;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 *                    (Not used with Shortcode class)
104 104
 	 * @return void
105 105
 	 */
106
-	public function register( $args = null ) {
107
-		\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
106
+	public function register($args = null) {
107
+		\add_shortcode($this->get_tag(), [$this, 'render']);
108 108
 	}
109 109
 
110 110
 	/**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 	 * @param  string|null $content Content between enclosing shortcodes.
131 131
 	 * @return string               The shortcode's HTML output.
132 132
 	 */
133
-	public function render( $atts, $content = null ) {
134
-		$atts = $this->atts_parser->parse_atts( $atts );
133
+	public function render($atts, $content = null) {
134
+		$atts = $this->atts_parser->parse_atts($atts);
135 135
 
136
-		$this->dependencies->enqueue( $atts );
136
+		$this->dependencies->enqueue($atts);
137 137
 
138
-		if ( ! $this->hasConfigKey( 'view' ) ) {
138
+		if ( ! $this->hasConfigKey('view')) {
139 139
 			return '';
140 140
 		}
141
-		$view = $this->getConfigKey( 'view' );
141
+		$view = $this->getConfigKey('view');
142 142
 
143
-		Assert\that( $view )->string()->notEmpty()->file();
143
+		Assert\that($view)->string()->notEmpty()->file();
144 144
 
145 145
 		ob_start();
146
-		include( $this->config['view'] );
146
+		include($this->config['view']);
147 147
 
148 148
 		return ob_get_clean();
149 149
 	}
Please login to merge, or discard this patch.
src/ShortcodeAttsParser.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		$config_key = null
56 56
 	) {
57 57
 
58
-		$this->processConfig( $config, $config_key );
58
+		$this->processConfig($config, $config_key);
59 59
 		$this->shortcode = $shortcode;
60 60
 	}
61 61
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 	 * @param  array $atts Attributes passed to the shortcode.
68 68
 	 * @return array       Validated attributes of the shortcode.
69 69
 	 */
70
-	public function parse_atts( $atts ) {
70
+	public function parse_atts($atts) {
71 71
 		$atts = \shortcode_atts(
72 72
 			$this->default_atts(),
73
-			$this->validated_atts( $atts ),
73
+			$this->validated_atts($atts),
74 74
 			$this->shortcode->get_tag()
75 75
 		);
76 76
 
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
 		$atts = array();
90 90
 
91
-		if ( array_key_exists( 'atts', $this->config ) ) {
92
-			array_walk( $this->config['atts'],
93
-				function ( $att_properties, $att_label ) use ( &$atts ) {
94
-					$atts[ $att_label ] = $att_properties['default'];
91
+		if (array_key_exists('atts', $this->config)) {
92
+			array_walk($this->config['atts'],
93
+				function($att_properties, $att_label) use (&$atts) {
94
+					$atts[$att_label] = $att_properties['default'];
95 95
 				}
96 96
 			);
97 97
 		}
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 	 * @param array $atts Attributes that were passed to the shortcode.
109 109
 	 * @return array Validated attributes.
110 110
 	 */
111
-	protected function validated_atts( $atts ) {
111
+	protected function validated_atts($atts) {
112 112
 
113
-		if ( array_key_exists( 'atts', $this->config ) ) {
114
-			array_walk( $this->config['atts'],
115
-				function ( $att_properties, $att_label ) use ( &$atts ) {
116
-					if ( array_key_exists( $att_label, $atts ) ) {
113
+		if (array_key_exists('atts', $this->config)) {
114
+			array_walk($this->config['atts'],
115
+				function($att_properties, $att_label) use (&$atts) {
116
+					if (array_key_exists($att_label, $atts)) {
117 117
 						$validate_function  = $att_properties['validate'];
118
-						$atts[ $att_label ] = $validate_function( $atts[ $att_label ] );
118
+						$atts[$att_label] = $validate_function($atts[$att_label]);
119 119
 					}
120 120
 				}
121 121
 			);
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Shortcode Attributes Parser Base Implementation.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Shortcode Attributes Parser Base Implementation.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.
src/ShortcodeAttsParserInterface.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,5 +29,5 @@
 block discarded – undo
29 29
 	 * @param  array $atts Attributes passed to the shortcode.
30 30
 	 * @return array       Validated attributes of the shortcode.
31 31
 	 */
32
-	public function parse_atts( $atts );
32
+	public function parse_atts($atts);
33 33
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Shortcode Attributes Parser Interface.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Shortcode Attributes Parser Interface.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.
src/ShortcodeInterface.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @param  string|null $content Content between enclosing shortcodes.
34 34
 	 * @return string               The shortcode's HTML output.
35 35
 	 */
36
-	public function render( $atts, $content = null );
36
+	public function render($atts, $content = null);
37 37
 
38 38
 	/**
39 39
 	 * Get the shortcode tag.
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Shortcode Interface.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Shortcode Interface.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.
src/ShortcodeUI.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		ConfigInterface $config,
64 64
 		DependencyManagerInterface $dependencies
65 65
 	) {
66
-		Assert\that( $shortcode_tag )->string()->notEmpty();
66
+		Assert\that($shortcode_tag)->string()->notEmpty();
67 67
 
68
-		$this->processConfig( $config );
68
+		$this->processConfig($config);
69 69
 
70 70
 		$this->shortcode_tag = $shortcode_tag;
71 71
 		$this->dependencies  = $dependencies;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 * @param mixed $context Data about the context in which the call is made.
80 80
 	 * @return void
81 81
 	 */
82
-	public function register( $context = null ) {
83
-		if ( ! $this->is_needed() ) {
82
+	public function register($context = null) {
83
+		if ( ! $this->is_needed()) {
84 84
 			return;
85 85
 		}
86 86
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	 * @param mixed $context Data about the context in which the call is made.
99 99
 	 * @return boolean Whether the shortcode is needed or not.
100 100
 	 */
101
-	protected function is_needed( $context = null ) {
101
+	protected function is_needed($context = null) {
102 102
 
103
-		$is_needed = $this->hasConfigKey( 'is_needed' )
104
-			? $this->getConfigKey( 'is_needed' )
103
+		$is_needed = $this->hasConfigKey('is_needed')
104
+			? $this->getConfigKey('is_needed')
105 105
 			: false;
106 106
 
107 107
 		// Return true if a callable 'is_needed' evaluates to true.
108
-		if ( is_callable( $is_needed ) && $is_needed( $context ) ) {
108
+		if (is_callable($is_needed) && $is_needed($context)) {
109 109
 			return true;
110 110
 		}
111 111
 
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * ShortcodeUI Class.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * ShortcodeUI Class.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.
src/ShortcodeManager.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Shortcode Manager.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Shortcode Manager.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 		ConfigInterface $config,
98 98
 		$config_key = null
99 99
 	) {
100
-		$this->processConfig( $config, $config_key );
100
+		$this->processConfig($config, $config_key);
101 101
 
102
-		if ( ! $this->hasConfigKey( self::KEY_TAGS ) ) {
102
+		if ( ! $this->hasConfigKey(self::KEY_TAGS)) {
103 103
 			return;
104 104
 		}
105 105
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function init_shortcodes() {
117 117
 
118
-		foreach ( $this->getConfigKey( self::KEY_TAGS ) as $tag => $config ) {
119
-			$this->init_shortcode( $tag );
118
+		foreach ($this->getConfigKey(self::KEY_TAGS) as $tag => $config) {
119
+			$this->init_shortcode($tag);
120 120
 		}
121 121
 	}
122 122
 
@@ -127,21 +127,21 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @param string $tag The tag of the shortcode to register.
129 129
 	 */
130
-	protected function init_shortcode( $tag ) {
131
-		$config_key            = $this->get_config_key( $tag );
132
-		$shortcode_class       = $this->get_shortcode_class( $tag );
133
-		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );
130
+	protected function init_shortcode($tag) {
131
+		$config_key            = $this->get_config_key($tag);
132
+		$shortcode_class       = $this->get_shortcode_class($tag);
133
+		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class($tag);
134 134
 
135 135
 		$this->shortcodes[] = new $shortcode_class(
136 136
 			$tag,
137
-			new $shortcode_atts_parser( $tag, $this->config, $config_key ),
137
+			new $shortcode_atts_parser($tag, $this->config, $config_key),
138 138
 			$this->dependencies,
139 139
 			$this->config,
140 140
 			$config_key
141 141
 		);
142 142
 
143
-		if ( $this->hasConfigKey( self::KEY_TAGS, $tag, self::KEY_UI ) ) {
144
-			$this->init_shortcode_ui( $tag );
143
+		if ($this->hasConfigKey(self::KEY_TAGS, $tag, self::KEY_UI)) {
144
+			$this->init_shortcode_ui($tag);
145 145
 		}
146 146
 	}
147 147
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 * @param string $tag The shortcode tag to get the config key for.
154 154
 	 * @return string Configuration key.
155 155
 	 */
156
-	protected function get_config_key( $tag ) {
157
-		return self::KEY_TAGS . self::CONFIG_SEPARATOR . $tag;
156
+	protected function get_config_key($tag) {
157
+		return self::KEY_TAGS.self::CONFIG_SEPARATOR.$tag;
158 158
 	}
159 159
 
160 160
 	/**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 * @param string $tag Shortcode tag to get the class for.
166 166
 	 * @return string Class name of the Shortcode.
167 167
 	 */
168
-	protected function get_shortcode_class( $tag ) {
169
-		$key             = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_CLASS ];
170
-		$shortcode_class = $this->hasConfigKey( $key )
171
-			? $this->getConfigKey( $key )
168
+	protected function get_shortcode_class($tag) {
169
+		$key             = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_CLASS];
170
+		$shortcode_class = $this->hasConfigKey($key)
171
+			? $this->getConfigKey($key)
172 172
 			: self::DEFAULT_SHORTCODE;
173 173
 		return $shortcode_class;
174 174
 	}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 	 * @param string $tag Shortcode tag to get the class for.
183 183
 	 * @return string Class name of the ShortcodeAttsParser.
184 184
 	 */
185
-	protected function get_shortcode_atts_parser_class( $tag ) {
186
-		$key         = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_ATTS_PARSER ];
187
-		$atts_parser = $this->hasConfigKey( $key )
188
-			? $this->getConfigKey( $key )
185
+	protected function get_shortcode_atts_parser_class($tag) {
186
+		$key         = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_ATTS_PARSER];
187
+		$atts_parser = $this->hasConfigKey($key)
188
+			? $this->getConfigKey($key)
189 189
 			: self::DEFAULT_SHORTCODE_ATTS_PARSER;
190 190
 		return $atts_parser;
191 191
 	}
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @param string $tag The tag of the shortcode to register the UI for.
199 199
 	 */
200
-	protected function init_shortcode_ui( $tag ) {
201
-		$shortcode_ui_class = $this->get_shortcode_ui_class( $tag );
200
+	protected function init_shortcode_ui($tag) {
201
+		$shortcode_ui_class = $this->get_shortcode_ui_class($tag);
202 202
 
203 203
 		$this->shortcode_uis[] = new $shortcode_ui_class(
204 204
 			$tag,
205 205
 			$this->dependencies,
206 206
 			$this->config,
207
-			$this->get_config_key( $tag )
207
+			$this->get_config_key($tag)
208 208
 		);
209 209
 	}
210 210
 
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	 * @param string $tag Configuration settings.
217 217
 	 * @return string Class name of the ShortcodeUI.
218 218
 	 */
219
-	protected function get_shortcode_ui_class( $tag ) {
220
-		$key      = [ self::KEY_TAGS, $tag, self::KEY_CUSTOM_UI ];
221
-		$ui_class = $this->hasConfigKey( $key )
222
-			? $this->getConfigKey( $key )
219
+	protected function get_shortcode_ui_class($tag) {
220
+		$key      = [self::KEY_TAGS, $tag, self::KEY_CUSTOM_UI];
221
+		$ui_class = $this->hasConfigKey($key)
222
+			? $this->getConfigKey($key)
223 223
 			: self::DEFAULT_SHORTCODE_UI;
224 224
 		return $ui_class;
225 225
 	}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return void
233 233
 	 */
234 234
 	public function register() {
235
-		array_walk( $this->shortcodes, function ( $shortcode ) {
235
+		array_walk($this->shortcodes, function($shortcode) {
236 236
 			/** @var ShortcodeInterface $shortcode */
237 237
 			$shortcode->register();
238 238
 		} );
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		// This hook only gets fired when Shortcode UI plugin is active.
241 241
 		\add_action(
242 242
 			'register_shortcode_ui',
243
-			[ $this, 'register_shortcode_ui', ]
243
+			[$this, 'register_shortcode_ui', ]
244 244
 		);
245 245
 	}
246 246
 
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function register_shortcode_ui() {
253 253
 		$template = $this->get_page_template();
254
-		$context  = [ 'page_template' => $template ];
254
+		$context  = ['page_template' => $template];
255 255
 
256
-		array_walk( $this->shortcode_uis,
257
-			function ( $shortcode_ui ) use ( $context ) {
256
+		array_walk($this->shortcode_uis,
257
+			function($shortcode_ui) use ($context) {
258 258
 				/** @var ShortcodeUIInterface $shortcode_ui */
259
-				$shortcode_ui->register( $context );
259
+				$shortcode_ui->register($context);
260 260
 			}
261 261
 		);
262 262
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	protected function get_page_template() {
272 272
 		$template = str_replace(
273
-			\trailingslashit( \get_stylesheet_directory() ),
273
+			\trailingslashit(\get_stylesheet_directory()),
274 274
 			'',
275 275
 			\get_page_template()
276 276
 		);
Please login to merge, or discard this patch.
src/ShortcodeUIInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * ShortcodeUIInterface Interface.
4
- *
5
- * @package   BrightNucleus\Shortcode
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * ShortcodeUIInterface Interface.
4
+	 *
5
+	 * @package   BrightNucleus\Shortcode
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Shortcode;
13 13
 
Please login to merge, or discard this patch.