Passed
Push — master ( 671e42...a49b57 )
by Alain
02:38
created
src/Shortcode.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
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,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 *                    (Not used with Shortcode class)
101 101
 	 * @return void
102 102
 	 */
103
-	public function register( $args = null ) {
104
-		if ( ! $this->is_needed( $args ) ) {
103
+	public function register($args = null) {
104
+		if ( ! $this->is_needed($args)) {
105 105
 			return;
106 106
 		}
107
-		\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
107
+		\add_shortcode($this->get_tag(), [$this, 'render']);
108 108
 	}
109 109
 
110 110
 	/**
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	 * @param mixed $context Data about the context in which the call is made.
116 116
 	 * @return boolean Whether the shortcode is needed or not.
117 117
 	 */
118
-	protected function is_needed( $context = null ) {
118
+	protected function is_needed($context = null) {
119 119
 
120
-		$is_needed = $this->hasConfigKey( 'is_needed' )
121
-			? $this->getConfigKey( 'is_needed' )
120
+		$is_needed = $this->hasConfigKey('is_needed')
121
+			? $this->getConfigKey('is_needed')
122 122
 			: false;
123 123
 
124
-		if ( is_callable( $is_needed ) ) {
125
-			return $is_needed( $context );
124
+		if (is_callable($is_needed)) {
125
+			return $is_needed($context);
126 126
 		}
127 127
 
128 128
 		return (bool) $is_needed;
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 *                              render.
155 155
 	 * @return string               The shortcode's HTML output.
156 156
 	 */
157
-	public function render( $atts, $content = null, $tag = null ) {
158
-		$atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() );
157
+	public function render($atts, $content = null, $tag = null) {
158
+		$atts = $this->atts_parser->parse_atts($atts, $this->get_tag());
159 159
 
160
-		$this->dependencies->enqueue( $atts );
160
+		$this->dependencies->enqueue($atts);
161 161
 
162
-		if ( ! $this->hasConfigKey( 'view' ) ) {
162
+		if ( ! $this->hasConfigKey('view')) {
163 163
 			return '';
164 164
 		}
165
-		$view = $this->getConfigKey( 'view' );
165
+		$view = $this->getConfigKey('view');
166 166
 
167
-		Assert\that( $view )->string()->notEmpty()->file();
167
+		Assert\that($view)->string()->notEmpty()->file();
168 168
 
169 169
 		ob_start();
170
-		include( $this->config['view'] );
170
+		include($this->config['view']);
171 171
 
172 172
 		return ob_get_clean();
173 173
 	}
Please login to merge, or discard this patch.
src/ShortcodeAttsParser.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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( (array) $atts ),
56
+			$this->validated_atts((array) $atts),
57 57
 			$tag
58 58
 		);
59 59
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
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
-		$atts_config = $this->getConfigKey( 'atts' );
79
-		array_walk( $atts_config,
80
-			function ( $att_properties, $att_label ) use ( &$atts ) {
81
-				$atts[ $att_label ] = $att_properties['default'];
78
+		$atts_config = $this->getConfigKey('atts');
79
+		array_walk($atts_config,
80
+			function($att_properties, $att_label) use (&$atts) {
81
+				$atts[$att_label] = $att_properties['default'];
82 82
 			}
83 83
 		);
84 84
 
@@ -94,18 +94,18 @@  discard block
 block discarded – undo
94 94
 	 * @param array $atts Attributes that were passed to the shortcode.
95 95
 	 * @return array Validated attributes.
96 96
 	 */
97
-	protected function validated_atts( $atts ) {
97
+	protected function validated_atts($atts) {
98 98
 
99
-		if ( ! $this->hasConfigKey( 'atts' ) ) {
99
+		if ( ! $this->hasConfigKey('atts')) {
100 100
 			return $atts;
101 101
 		}
102 102
 
103
-		$atts_config = $this->getConfigKey( 'atts' );
104
-		array_walk( $atts_config,
105
-			function ( $att_properties, $att_label ) use ( &$atts ) {
106
-				if ( array_key_exists( $att_label, $atts ) ) {
103
+		$atts_config = $this->getConfigKey('atts');
104
+		array_walk($atts_config,
105
+			function($att_properties, $att_label) use (&$atts) {
106
+				if (array_key_exists($att_label, $atts)) {
107 107
 					$validate_function  = $att_properties['validate'];
108
-					$atts[ $att_label ] = $validate_function( $atts[ $att_label ] );
108
+					$atts[$att_label] = $validate_function($atts[$att_label]);
109 109
 				}
110 110
 			}
111 111
 		);
Please login to merge, or discard this patch.
src/ShortcodeManager.php 1 patch
Spacing   +34 added lines, -34 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.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		ConfigInterface $config,
94 94
 		DependencyManagerInterface $dependencies
95 95
 	) {
96
-		$this->processConfig( $config );
96
+		$this->processConfig($config);
97 97
 		$this->dependencies = $dependencies;
98 98
 
99 99
 		$this->init_shortcodes();
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @since 0.1.0
106 106
 	 */
107 107
 	public function init_shortcodes() {
108
-		foreach ( $this->getConfigKeys() as $tag ) {
109
-			$this->init_shortcode( $tag );
108
+		foreach ($this->getConfigKeys() as $tag) {
109
+			$this->init_shortcode($tag);
110 110
 		}
111 111
 	}
112 112
 
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param string $tag The tag of the shortcode to register.
119 119
 	 */
120
-	protected function init_shortcode( $tag ) {
121
-		$shortcode_class       = $this->get_shortcode_class( $tag );
122
-		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );
120
+	protected function init_shortcode($tag) {
121
+		$shortcode_class       = $this->get_shortcode_class($tag);
122
+		$shortcode_atts_parser = $this->get_shortcode_atts_parser_class($tag);
123 123
 
124 124
 		$atts_parser        = new $shortcode_atts_parser(
125
-			$this->config->getSubConfig( $tag )
125
+			$this->config->getSubConfig($tag)
126 126
 		);
127 127
 		$this->shortcodes[] = new $shortcode_class(
128 128
 			$tag,
129
-			$this->config->getSubConfig( $tag ),
129
+			$this->config->getSubConfig($tag),
130 130
 			$atts_parser,
131 131
 			$this->dependencies
132 132
 		);
133 133
 
134
-		if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) {
135
-			$this->init_shortcode_ui( $tag );
134
+		if ($this->hasConfigKey($tag, self::KEY_UI)) {
135
+			$this->init_shortcode_ui($tag);
136 136
 		}
137 137
 	}
138 138
 
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 * @param string $tag Shortcode tag to get the class for.
145 145
 	 * @return string Class name of the Shortcode.
146 146
 	 */
147
-	protected function get_shortcode_class( $tag ) {
148
-		$shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS )
149
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS )
147
+	protected function get_shortcode_class($tag) {
148
+		$shortcode_class = $this->hasConfigKey($tag, self::KEY_CUSTOM_CLASS)
149
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_CLASS)
150 150
 			: self::DEFAULT_SHORTCODE;
151 151
 		return $shortcode_class;
152 152
 	}
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 * @param string $tag Shortcode tag to get the class for.
161 161
 	 * @return string Class name of the ShortcodeAttsParser.
162 162
 	 */
163
-	protected function get_shortcode_atts_parser_class( $tag ) {
164
-		$atts_parser = $this->hasConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
165
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
163
+	protected function get_shortcode_atts_parser_class($tag) {
164
+		$atts_parser = $this->hasConfigKey($tag, self::KEY_CUSTOM_ATTS_PARSER)
165
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_ATTS_PARSER)
166 166
 			: self::DEFAULT_SHORTCODE_ATTS_PARSER;
167 167
 		return $atts_parser;
168 168
 	}
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @param string $tag The tag of the shortcode to register the UI for.
176 176
 	 */
177
-	protected function init_shortcode_ui( $tag ) {
178
-		$shortcode_ui_class = $this->get_shortcode_ui_class( $tag );
177
+	protected function init_shortcode_ui($tag) {
178
+		$shortcode_ui_class = $this->get_shortcode_ui_class($tag);
179 179
 
180 180
 		$this->shortcode_uis[] = new $shortcode_ui_class(
181 181
 			$tag,
182
-			$this->config->getSubConfig( $tag, self::KEY_UI ),
182
+			$this->config->getSubConfig($tag, self::KEY_UI),
183 183
 			$this->dependencies
184 184
 		);
185 185
 	}
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 * @param string $tag Configuration settings.
193 193
 	 * @return string Class name of the ShortcodeUI.
194 194
 	 */
195
-	protected function get_shortcode_ui_class( $tag ) {
196
-		$ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI )
197
-			? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI )
195
+	protected function get_shortcode_ui_class($tag) {
196
+		$ui_class = $this->hasConfigKey($tag, self::KEY_CUSTOM_UI)
197
+			? $this->getConfigKey($tag, self::KEY_CUSTOM_UI)
198 198
 			: self::DEFAULT_SHORTCODE_UI;
199 199
 		return $ui_class;
200 200
 	}
@@ -208,18 +208,18 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function register() {
210 210
 		$template = $this->get_page_template();
211
-		$context  = [ 'page_template' => $template ];
211
+		$context  = ['page_template' => $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
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	protected function get_page_template() {
234 234
 		$template = str_replace(
235
-			\trailingslashit( \get_stylesheet_directory() ),
235
+			\trailingslashit(\get_stylesheet_directory()),
236 236
 			'',
237 237
 			\get_page_template()
238 238
 		);
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function register_shortcode_ui() {
248 248
 		$template = $this->get_page_template();
249
-		$context  = [ 'page_template' => $template ];
249
+		$context  = ['page_template' => $template];
250 250
 
251
-		array_walk( $this->shortcode_uis,
252
-			function ( $shortcode_ui ) use ( $context ) {
251
+		array_walk($this->shortcode_uis,
252
+			function($shortcode_ui) use ($context) {
253 253
 				/** @var ShortcodeUIInterface $shortcode_ui */
254
-				$shortcode_ui->register( $context );
254
+				$shortcode_ui->register($context);
255 255
 			}
256 256
 		);
257 257
 	}
Please login to merge, or discard this patch.
src/ShortcodeUI.php 1 patch
Spacing   +9 added lines, -9 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,15 +98,15 @@  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 UI 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 ) ) {
109
-			return $is_needed( $context );
108
+		if (is_callable($is_needed)) {
109
+			return $is_needed($context);
110 110
 		}
111 111
 
112 112
 		return (bool) $is_needed;
Please login to merge, or discard this patch.