Passed
Push — master ( 82e2c7...cd28b2 )
by Alain
01:23
created
src/ShortcodeManager.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @var ShortcodeInterface[]
59 59
 	 */
60
-	protected $shortcodes = [ ];
60
+	protected $shortcodes = [];
61 61
 
62 62
 	/**
63 63
 	 * DependencyManagerInterface implementation.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @var ShortcodeUIInterface[]
77 77
 	 */
78
-	protected $shortcode_uis = [ ];
78
+	protected $shortcode_uis = [];
79 79
 
80 80
 	/**
81 81
 	 * Instantiate a ShortcodeManager object.
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		ConfigInterface $config,
93 93
 		DependencyManager $dependencies = null
94 94
 	) {
95
-		$this->processConfig( $config );
95
+		$this->processConfig($config);
96 96
 		$this->dependencies = $dependencies;
97 97
 
98 98
 		$this->init_shortcodes();
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @since 0.1.0
105 105
 	 */
106 106
 	public function init_shortcodes() {
107
-		foreach ( $this->getConfigKeys() as $tag ) {
108
-			$this->init_shortcode( $tag );
107
+		foreach ($this->getConfigKeys() as $tag) {
108
+			$this->init_shortcode($tag);
109 109
 		}
110 110
 	}
111 111
 
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param string $tag The tag of the shortcode to register.
118 118
 	 */
119
-	protected function init_shortcode( $tag ) {
120
-		$shortcode_class       = $this->get_shortcode_class( $tag );
121
-		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );
119
+	protected function init_shortcode($tag) {
120
+		$shortcode_class       = $this->get_shortcode_class($tag);
121
+		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class($tag);
122 122
 
123 123
 		$atts_parser        = new $shortcode_atts_parser(
124
-			$this->config->getSubConfig( $tag )
124
+			$this->config->getSubConfig($tag)
125 125
 		);
126 126
 		$this->shortcodes[] = new $shortcode_class(
127 127
 			$tag,
128
-			$this->config->getSubConfig( $tag ),
128
+			$this->config->getSubConfig($tag),
129 129
 			$atts_parser,
130 130
 			$this->dependencies
131 131
 		);
132 132
 
133
-		if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) {
134
-			$this->init_shortcode_ui( $tag );
133
+		if ($this->hasConfigKey($tag, self::KEY_UI)) {
134
+			$this->init_shortcode_ui($tag);
135 135
 		}
136 136
 	}
137 137
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 * @param string $tag Shortcode tag to get the class for.
144 144
 	 * @return string Class name of the Shortcode.
145 145
 	 */
146
-	protected function get_shortcode_class( $tag ) {
147
-		$shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS )
148
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS )
146
+	protected function get_shortcode_class($tag) {
147
+		$shortcode_class = $this->hasConfigKey($tag, self::KEY_CUSTOM_CLASS)
148
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_CLASS)
149 149
 			: self::DEFAULT_SHORTCODE;
150 150
 		return $shortcode_class;
151 151
 	}
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @param string $tag Shortcode tag to get the class for.
160 160
 	 * @return string Class name of the ShortcodeAttsParser.
161 161
 	 */
162
-	protected function get_shortcode_atts_parser_class( $tag ) {
163
-		$atts_parser = $this->hasConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
164
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
162
+	protected function get_shortcode_atts_parser_class($tag) {
163
+		$atts_parser = $this->hasConfigKey($tag, self::KEY_CUSTOM_ATTS_PARSER)
164
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_ATTS_PARSER)
165 165
 			: self::DEFAULT_SHORTCODE_ATTS_PARSER;
166 166
 		return $atts_parser;
167 167
 	}
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @param string $tag The tag of the shortcode to register the UI for.
175 175
 	 */
176
-	protected function init_shortcode_ui( $tag ) {
177
-		$shortcode_ui_class = $this->get_shortcode_ui_class( $tag );
176
+	protected function init_shortcode_ui($tag) {
177
+		$shortcode_ui_class = $this->get_shortcode_ui_class($tag);
178 178
 
179 179
 		$this->shortcode_uis[] = new $shortcode_ui_class(
180 180
 			$tag,
181
-			$this->config->getSubConfig( $tag, self::KEY_UI ),
181
+			$this->config->getSubConfig($tag, self::KEY_UI),
182 182
 			$this->dependencies
183 183
 		);
184 184
 	}
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 	 * @param string $tag Configuration settings.
192 192
 	 * @return string Class name of the ShortcodeUI.
193 193
 	 */
194
-	protected function get_shortcode_ui_class( $tag ) {
195
-		$ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI )
196
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI )
194
+	protected function get_shortcode_ui_class($tag) {
195
+		$ui_class = $this->hasConfigKey($tag, self::KEY_CUSTOM_UI)
196
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_UI)
197 197
 			: self::DEFAULT_SHORTCODE_UI;
198 198
 		return $ui_class;
199 199
 	}
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 	 * @param mixed $context Optional. Context information to pass to shortcode.
207 207
 	 * @return void
208 208
 	 */
209
-	public function register( $context = null ) {
210
-		$context                  = $this->validate_context( $context );
209
+	public function register($context = null) {
210
+		$context                  = $this->validate_context($context);
211 211
 		$context['page_template'] = $this->get_page_template();
212 212
 
213
-		array_walk( $this->shortcodes,
214
-			function ( $shortcode ) use ( $context ) {
213
+		array_walk($this->shortcodes,
214
+			function($shortcode) use ($context) {
215 215
 				/** @var ShortcodeInterface $shortcode */
216
-				$shortcode->register( $context );
216
+				$shortcode->register($context);
217 217
 			} );
218 218
 
219 219
 		// This hook only gets fired when Shortcode UI plugin is active.
220 220
 		\add_action(
221 221
 			'register_shortcode_ui',
222
-			[ $this, 'register_shortcode_ui', ]
222
+			[$this, 'register_shortcode_ui', ]
223 223
 		);
224 224
 	}
225 225
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 * @param mixed $context The context as passed in by WordPress.
232 232
 	 * @return array Validated context.
233 233
 	 */
234
-	protected function validate_context( $context ) {
235
-		if ( is_string( $context ) ) {
236
-			return [ 'wp_context' => $context ];
234
+	protected function validate_context($context) {
235
+		if (is_string($context)) {
236
+			return ['wp_context' => $context];
237 237
 		}
238 238
 		return (array) $context;
239 239
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	protected function get_page_template() {
249 249
 		$template = str_replace(
250
-			\trailingslashit( \get_stylesheet_directory() ),
250
+			\trailingslashit(\get_stylesheet_directory()),
251 251
 			'',
252 252
 			\get_page_template()
253 253
 		);
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function register_shortcode_ui() {
263 263
 		$template = $this->get_page_template();
264
-		$context  = [ 'page_template' => $template ];
264
+		$context  = ['page_template' => $template];
265 265
 
266
-		array_walk( $this->shortcode_uis,
267
-			function ( $shortcode_ui ) use ( $context ) {
266
+		array_walk($this->shortcode_uis,
267
+			function($shortcode_ui) use ($context) {
268 268
 				/** @var ShortcodeUIInterface $shortcode_ui */
269
-				$shortcode_ui->register( $context );
269
+				$shortcode_ui->register($context);
270 270
 			}
271 271
 		);
272 272
 	}
Please login to merge, or discard this patch.