Passed
Push — master ( 63fa33...82e2c7 )
by Alain
02:47
created
src/Shortcode.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 		DependencyManager $dependencies = null
91 91
 	) {
92 92
 
93
-		Assert\that( $shortcode_tag )->string()->notEmpty();
93
+		Assert\that($shortcode_tag)->string()->notEmpty();
94 94
 
95
-		$this->processConfig( $config );
95
+		$this->processConfig($config);
96 96
 
97 97
 		$this->shortcode_tag = $shortcode_tag;
98 98
 		$this->atts_parser   = $atts_parser;
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	 * @param mixed $context Optional. Arguments to pass on to the Registrable.
108 108
 	 * @return void
109 109
 	 */
110
-	public function register( $context = null ) {
111
-		if ( ! $this->is_needed( $context ) ) {
110
+	public function register($context = null) {
111
+		if ( ! $this->is_needed($context)) {
112 112
 			return;
113 113
 		}
114 114
 		$this->context = $context;
115 115
 
116
-		\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
116
+		\add_shortcode($this->get_tag(), [$this, 'render']);
117 117
 	}
118 118
 
119 119
 	/**
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 	 * @param mixed $context Data about the context in which the call is made.
125 125
 	 * @return boolean Whether the shortcode is needed or not.
126 126
 	 */
127
-	protected function is_needed( $context = null ) {
127
+	protected function is_needed($context = null) {
128 128
 
129
-		$is_needed = $this->hasConfigKey( 'is_needed' )
130
-			? $this->getConfigKey( 'is_needed' )
129
+		$is_needed = $this->hasConfigKey('is_needed')
130
+			? $this->getConfigKey('is_needed')
131 131
 			: false;
132 132
 
133
-		if ( is_callable( $is_needed ) ) {
134
-			return $is_needed( $context );
133
+		if (is_callable($is_needed)) {
134
+			return $is_needed($context);
135 135
 		}
136 136
 
137 137
 		return (bool) $is_needed;
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 	 *                              render.
164 164
 	 * @return string               The shortcode's HTML output.
165 165
 	 */
166
-	public function render( $atts, $content = null, $tag = null ) {
166
+	public function render($atts, $content = null, $tag = null) {
167 167
 		$context = $this->context;
168
-		$atts    = $this->atts_parser->parse_atts( $atts, $this->get_tag() );
168
+		$atts    = $this->atts_parser->parse_atts($atts, $this->get_tag());
169 169
 
170
-		if ( $this->dependencies ) {
171
-			$this->dependencies->enqueue( $atts );
170
+		if ($this->dependencies) {
171
+			$this->dependencies->enqueue($atts);
172 172
 		}
173 173
 
174
-		if ( ! $this->hasConfigKey( 'view' ) ) {
174
+		if ( ! $this->hasConfigKey('view')) {
175 175
 			return '';
176 176
 		}
177
-		$view = $this->getConfigKey( 'view' );
177
+		$view = $this->getConfigKey('view');
178 178
 
179
-		Assert\that( $view )->string()->notEmpty()->file();
179
+		Assert\that($view)->string()->notEmpty()->file();
180 180
 
181 181
 		ob_start();
182
-		include( $this->config['view'] );
182
+		include($this->config['view']);
183 183
 
184 184
 		return ob_get_clean();
185 185
 	}
Please login to merge, or discard this patch.
src/ShortcodeManager.php 1 patch
Spacing   +39 added lines, -39 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 );
211
-		$context['page_template'] = $this->get_page_template();;
209
+	public function register($context = null) {
210
+		$context                  = $this->validate_context($context);
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.