Completed
Push — develop ( c1cebe...93b04b )
by Paul
01:58
created
src/Facade.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 	 * @return mixed
31 31
 	 * @throws \RuntimeException
32 32
 	 */
33
-	public static function __callStatic( $method, $args )
33
+	public static function __callStatic($method, $args)
34 34
 	{
35 35
 		$instance = static::getFacadeRoot();
36 36
 
37
-		if( !$instance ) {
38
-			throw new RuntimeException( 'A facade root has not been set.' );
37
+		if (!$instance) {
38
+			throw new RuntimeException('A facade root has not been set.');
39 39
 		}
40 40
 
41
-		return $instance->$method( ...$args );
41
+		return $instance->$method(...$args);
42 42
 	}
43 43
 
44 44
 	/**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public static function getFacadeRoot()
70 70
 	{
71
-		return static::resolveFacadeInstance( static::getFacadeAccessor() );
71
+		return static::resolveFacadeInstance(static::getFacadeAccessor());
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return void
78 78
 	 */
79
-	public static function setFacadeApplication( Application $app )
79
+	public static function setFacadeApplication(Application $app)
80 80
 	{
81 81
 		static::$app = $app;
82 82
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	protected static function getFacadeAccessor()
92 92
 	{
93
-		throw new RuntimeException( 'Facade does not implement getFacadeAccessor method.' );
93
+		throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
94 94
 	}
95 95
 
96 96
 	/**
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return mixed
102 102
 	 */
103
-	protected static function resolveFacadeInstance( $name )
103
+	protected static function resolveFacadeInstance($name)
104 104
 	{
105
-		if( is_object( $name )) {
105
+		if (is_object($name)) {
106 106
 			return $name;
107 107
 		}
108 108
 
109
-		if( isset( static::$resolvedInstance[$name] )) {
109
+		if (isset(static::$resolvedInstance[$name])) {
110 110
 			return static::$resolvedInstance[$name];
111 111
 		}
112 112
 
Please login to merge, or discard this patch.
src/Container.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function getInstance()
34 34
 	{
35
-		if( is_null( static::$instance )) {
35
+		if (is_null(static::$instance)) {
36 36
 			static::$instance = new static;
37 37
 		}
38 38
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @return mixed
49 49
 	 */
50
-	public function bind( $alias, $concrete )
50
+	public function bind($alias, $concrete)
51 51
 	{
52 52
 		$this->services[$alias] = $concrete;
53 53
 	}
@@ -61,20 +61,20 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return mixed
63 63
 	 */
64
-	public function make( $abstract )
64
+	public function make($abstract)
65 65
 	{
66
-		$service = isset( $this->services[$abstract] )
66
+		$service = isset($this->services[$abstract])
67 67
 			? $this->services[$abstract]
68
-			: $this->addNamespace( $abstract );
68
+			: $this->addNamespace($abstract);
69 69
 
70
-		if( is_callable( $service )) {
71
-			return call_user_func_array( $service, [$this] );
70
+		if (is_callable($service)) {
71
+			return call_user_func_array($service, [$this]);
72 72
 		}
73
-		if( is_object( $service )) {
73
+		if (is_object($service)) {
74 74
 			return $service;
75 75
 		}
76 76
 
77
-		return $this->resolve( $service );
77
+		return $this->resolve($service);
78 78
 	}
79 79
 
80 80
 	/**
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return void
87 87
 	 */
88
-	public function singleton( $abstract, $concrete )
88
+	public function singleton($abstract, $concrete)
89 89
 	{
90
-		$this->bind( $abstract, $this->make( $concrete ));
90
+		$this->bind($abstract, $this->make($concrete));
91 91
 	}
92 92
 
93 93
 	/**
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return mixed
99 99
 	 */
100
-	public function __get( $service )
100
+	public function __get($service)
101 101
 	{
102
-		return $this->make( $service );
102
+		return $this->make($service);
103 103
 	}
104 104
 
105 105
 	/**
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return void
112 112
 	 */
113
-	public function __set( $service, $callback )
113
+	public function __set($service, $callback)
114 114
 	{
115
-		$this->bind( $service, $callback );
115
+		$this->bind($service, $callback);
116 116
 	}
117 117
 
118 118
 	/**
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string
124 124
 	 */
125
-	protected function addNamespace( $abstract )
125
+	protected function addNamespace($abstract)
126 126
 	{
127
-		if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) {
127
+		if (strpos($abstract, __NAMESPACE__) === false && !class_exists($abstract)) {
128 128
 			$abstract = __NAMESPACE__ . "\\$abstract";
129 129
 		}
130 130
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * @return void
140 140
 	 * @throws BindingResolutionException
141 141
 	 */
142
-	protected function notInstantiable( $concrete )
142
+	protected function notInstantiable($concrete)
143 143
 	{
144 144
 		$message = "Target [$concrete] is not instantiable.";
145 145
 
146
-		throw new BindingResolutionException( $message );
146
+		throw new BindingResolutionException($message);
147 147
 	}
148 148
 
149 149
 	/**
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
 	 * @return mixed
155 155
 	 * @throws BindingResolutionException
156 156
 	 */
157
-	protected function resolve( $concrete )
157
+	protected function resolve($concrete)
158 158
 	{
159
-		if( $concrete instanceof Closure ) {
160
-			return $concrete( $this );
159
+		if ($concrete instanceof Closure) {
160
+			return $concrete($this);
161 161
 		}
162 162
 
163
-		$reflector = new ReflectionClass( $concrete );
163
+		$reflector = new ReflectionClass($concrete);
164 164
 
165
-		if( !$reflector->isInstantiable() ) {
166
-			return $this->notInstantiable( $concrete );
165
+		if (!$reflector->isInstantiable()) {
166
+			return $this->notInstantiable($concrete);
167 167
 		}
168 168
 
169
-		if( is_null(( $constructor = $reflector->getConstructor() ))) {
169
+		if (is_null(($constructor = $reflector->getConstructor()))) {
170 170
 			return new $concrete;
171 171
 		}
172 172
 
173 173
 		return $reflector->newInstanceArgs(
174
-			$this->resolveDependencies( $constructor->getParameters() )
174
+			$this->resolveDependencies($constructor->getParameters())
175 175
 		);
176 176
 	}
177 177
 
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	 * @return mixed
182 182
 	 * @throws BindingResolutionException
183 183
 	 */
184
-	protected function resolveClass( ReflectionParameter $parameter )
184
+	protected function resolveClass(ReflectionParameter $parameter)
185 185
 	{
186 186
 		try {
187
-			return $this->make( $parameter->getClass()->name );
187
+			return $this->make($parameter->getClass()->name);
188 188
 		}
189
-		catch( BindingResolutionException $e ) {
190
-			if( $parameter->isOptional() ) {
189
+		catch (BindingResolutionException $e) {
190
+			if ($parameter->isOptional()) {
191 191
 				return $parameter->getDefaultValue();
192 192
 			}
193 193
 			throw $e;
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return array
201 201
 	 */
202
-	protected function resolveDependencies( array $dependencies )
202
+	protected function resolveDependencies(array $dependencies)
203 203
 	{
204 204
 		$results = [];
205 205
 
206
-		foreach( $dependencies as $dependency ) {
206
+		foreach ($dependencies as $dependency) {
207 207
 			// If the class is null, the dependency is a string or some other primitive type
208
-			$results[] = !is_null( $class = $dependency->getClass() )
209
-				? $this->resolveClass( $dependency )
208
+			$results[] = !is_null($class = $dependency->getClass())
209
+				? $this->resolveClass($dependency)
210 210
 				: null;
211 211
 		}
212 212
 
Please login to merge, or discard this patch.
src/AliasLoader.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	protected $registered = false;
27 27
 
28
-	private function __construct( array $aliases )
28
+	private function __construct(array $aliases)
29 29
 	{
30 30
 		$this->aliases = $aliases;
31 31
 	}
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return AliasLoader
40 40
 	 */
41
-	public static function getInstance( array $aliases = [] )
41
+	public static function getInstance(array $aliases = [])
42 42
 	{
43
-		if( is_null( static::$instance )) {
44
-			return static::$instance = new static( $aliases );
43
+		if (is_null(static::$instance)) {
44
+			return static::$instance = new static($aliases);
45 45
 		}
46 46
 
47
-		$aliases = array_merge( static::$instance->aliases, $aliases );
47
+		$aliases = array_merge(static::$instance->aliases, $aliases);
48 48
 
49 49
 		static::$instance->aliases = $aliases;
50 50
 
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return bool|null
60 60
 	 */
61
-	public function load( $alias )
61
+	public function load($alias)
62 62
 	{
63
-		if( isset( $this->aliases[$alias] )) {
64
-			return class_alias( $this->aliases[$alias], $alias );
63
+		if (isset($this->aliases[$alias])) {
64
+			return class_alias($this->aliases[$alias], $alias);
65 65
 		}
66 66
 	}
67 67
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function register()
74 74
 	{
75
-		if( !$this->registered ) {
76
-			spl_autoload_register( [$this, 'load'], true, true );
75
+		if (!$this->registered) {
76
+			spl_autoload_register([$this, 'load'], true, true);
77 77
 			$this->registered = true;
78 78
 		}
79 79
 	}
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@  discard block
 block discarded – undo
11 11
 	public function __construct()
12 12
 	{
13 13
 		Facade::clearResolvedInstances();
14
-		Facade::setFacadeApplication( $this );
14
+		Facade::setFacadeApplication($this);
15 15
 		$this->registerAliases();
16 16
 	}
17 17
 
18 18
 	public function init()
19 19
 	{
20
-		$controller = $this->make( 'Controller' );
20
+		$controller = $this->make('Controller');
21 21
 
22 22
 		// Action hooks
23
-		add_action( 'after_setup_theme',      [$controller, 'afterSetupTheme'], 20 );
24
-		add_action( 'login_head',             [$controller, 'login'] );
25
-		add_action( 'wp_enqueue_scripts',     [$controller, 'registerAssets'] );
26
-		add_action( 'customize_register',     [$controller, 'registerCustomizer'] );
27
-		add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] );
28
-		add_action( 'widgets_init',           [$controller, 'registerSidebars'] );
23
+		add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20);
24
+		add_action('login_head', [$controller, 'login']);
25
+		add_action('wp_enqueue_scripts', [$controller, 'registerAssets']);
26
+		add_action('customize_register', [$controller, 'registerCustomizer']);
27
+		add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']);
28
+		add_action('widgets_init', [$controller, 'registerSidebars']);
29 29
 
30 30
 		// Filter hooks
31
-		add_filter( 'template_include',       [$controller, 'filterTemplate'] );
32
-		add_filter( 'login_headertitle',      [$controller, 'filterLoginTitle'] );
33
-		add_filter( 'login_headerurl',        [$controller, 'filterLoginUrl'] );
31
+		add_filter('template_include', [$controller, 'filterTemplate']);
32
+		add_filter('login_headertitle', [$controller, 'filterLoginTitle']);
33
+		add_filter('login_headerurl', [$controller, 'filterLoginUrl']);
34 34
 
35
-		foreach( $this->getTemplateTypes() as $type ) {
36
-			add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] );
35
+		foreach ($this->getTemplateTypes() as $type) {
36
+			add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']);
37 37
 		}
38 38
 	}
39 39
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 			'Utility'     => Facades\Utility::class,
52 52
 		];
53 53
 
54
-		$aliases = apply_filters( 'castor/register/aliases', $aliases );
54
+		$aliases = apply_filters('castor/register/aliases', $aliases);
55 55
 
56
-		AliasLoader::getInstance( $aliases )->register();
56
+		AliasLoader::getInstance($aliases)->register();
57 57
 	}
58 58
 
59 59
 	/**
Please login to merge, or discard this patch.
src/Helpers/Development.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 	public function capture()
10 10
 	{
11 11
 		ob_start();
12
-		call_user_func_array( [$this, 'print'], func_get_args() );
12
+		call_user_func_array([$this, 'print'], func_get_args());
13 13
 		return ob_get_clean();
14 14
 	}
15 15
 
16 16
 	public function className()
17 17
 	{
18
-		return $this->isDev() && in_array( DEV, ['css', true] )
18
+		return $this->isDev() && in_array(DEV, ['css', true])
19 19
 			? 'dev'
20 20
 			: '';
21 21
 	}
22 22
 
23 23
 	public function debug()
24 24
 	{
25
-		call_user_func_array( [$this, 'print'], func_get_args() );
25
+		call_user_func_array([$this, 'print'], func_get_args());
26 26
 	}
27 27
 
28 28
 	public function isDev()
29 29
 	{
30
-		return defined( 'DEV' ) && !!DEV && WP_ENV == 'development';
30
+		return defined('DEV') && !!DEV && WP_ENV == 'development';
31 31
 	}
32 32
 
33 33
 	public function isProduction()
@@ -39,44 +39,44 @@  discard block
 block discarded – undo
39 39
 	{
40 40
 		$args = func_num_args();
41 41
 
42
-		if( $args == 1 ) {
43
-			printf( '<div class="print__r"><pre>%s</pre></div>',
44
-				htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' )
42
+		if ($args == 1) {
43
+			printf('<div class="print__r"><pre>%s</pre></div>',
44
+				htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8')
45 45
 			);
46 46
 		}
47
-		else if( $args > 1 ) {
47
+		else if ($args > 1) {
48 48
 			echo '<div class="print__r_group">';
49
-			foreach( func_get_args() as $value ) {
50
-				$this->print( $value );
49
+			foreach (func_get_args() as $value) {
50
+				$this->print($value);
51 51
 			}
52 52
 			echo '</div>';
53 53
 		}
54 54
 	}
55 55
 
56
-	public function printFiltersFor( $hook = '' )
56
+	public function printFiltersFor($hook = '')
57 57
 	{
58 58
 		global $wp_filter;
59
-		if( empty( $hook ) || !isset( $wp_filter[$hook] ))return;
60
-		$this->print( $wp_filter[ $hook ] );
59
+		if (empty($hook) || !isset($wp_filter[$hook]))return;
60
+		$this->print($wp_filter[$hook]);
61 61
 	}
62 62
 
63 63
 	public function printTemplatePaths()
64 64
 	{
65
-		if( $this->isDev() && ( DEV == 'templates' || DEV === true )) {
66
-			$templates = array_keys( array_flip( $this->templatePaths ));
67
-			$templates = array_map( function( $key, $value ) {
68
-				return sprintf( '[%s] => %s', $key, $value );
69
-			}, array_keys( $templates ), $templates );
65
+		if ($this->isDev() && (DEV == 'templates' || DEV === true)) {
66
+			$templates = array_keys(array_flip($this->templatePaths));
67
+			$templates = array_map(function($key, $value) {
68
+				return sprintf('[%s] => %s', $key, $value);
69
+			}, array_keys($templates), $templates);
70 70
 
71
-			$this->print( implode( "\n", $templates ));
71
+			$this->print(implode("\n", $templates));
72 72
 		}
73 73
 	}
74 74
 
75
-	public function storeTemplatePath( $template )
75
+	public function storeTemplatePath($template)
76 76
 	{
77
-		if( is_string( $template )) {
78
-			$themeName = basename( strstr( $template, '/templates/', true ));
79
-			$this->templatePaths[] = $themeName . strstr( $template, '/templates/' );
77
+		if (is_string($template)) {
78
+			$themeName = basename(strstr($template, '/templates/', true));
79
+			$this->templatePaths[] = $themeName . strstr($template, '/templates/');
80 80
 		}
81 81
 	}
82 82
 }
Please login to merge, or discard this patch.
src/Helpers/Utility.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@  discard block
 block discarded – undo
7 7
 	/**
8 8
 	 * @return string
9 9
 	 */
10
-	public function buildAttributes( array $atts = [] )
10
+	public function buildAttributes(array $atts = [])
11 11
 	{
12 12
 		$attributes = [];
13
-		foreach( $atts as $key => $value ) {
14
-			$attributes[] = sprintf( '%s="%s"', $key, $value );
13
+		foreach ($atts as $key => $value) {
14
+			$attributes[] = sprintf('%s="%s"', $key, $value);
15 15
 		}
16
-		return implode( ' ', $attributes );
16
+		return implode(' ', $attributes);
17 17
 	}
18 18
 
19 19
 	/**
20 20
 	 * @return string
21 21
 	 */
22
-	public function buildAttributesFor( $tag, array $atts = [] )
22
+	public function buildAttributesFor($tag, array $atts = [])
23 23
 	{
24 24
 		return $this->buildAttributes(
25
-			wp_parse_args( $atts, apply_filters( "castor/render/$tag/attributes", [] ))
25
+			wp_parse_args($atts, apply_filters("castor/render/$tag/attributes", []))
26 26
 		);
27 27
 	}
28 28
 
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return string
34 34
 	 */
35
-	public function buildClassName( $name, $path = '' )
35
+	public function buildClassName($name, $path = '')
36 36
 	{
37
-		$className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name )));
38
-		$className = implode( '', $className );
37
+		$className = array_map('ucfirst', array_map('strtolower', preg_split('/[-_]/', $name)));
38
+		$className = implode('', $className);
39 39
 
40
-		return !empty( $path )
41
-			? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ))
40
+		return !empty($path)
41
+			? str_replace('\\\\', '\\', sprintf('%s\%s', $path, $className))
42 42
 			: $className;
43 43
 	}
44 44
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return string
50 50
 	 */
51
-	public function buildMethodName( $name, $prefix = 'get' )
51
+	public function buildMethodName($name, $prefix = 'get')
52 52
 	{
53
-		return lcfirst( $this->buildClassName( $prefix . '-' . $name ));
53
+		return lcfirst($this->buildClassName($prefix . '-' . $name));
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return string
62 62
 	 */
63
-	public function endWith( $suffix, $string, $unique = true )
63
+	public function endWith($suffix, $string, $unique = true)
64 64
 	{
65
-		return $unique && $this->endsWith( $suffix, $string )
65
+		return $unique && $this->endsWith($suffix, $string)
66 66
 			? $string
67 67
 			: $string . $suffix;
68 68
 	}
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return string
75 75
 	 */
76
-	public function endsWith( $needle, $haystack )
76
+	public function endsWith($needle, $haystack)
77 77
 	{
78
-		$length = strlen( $needle );
78
+		$length = strlen($needle);
79 79
 		return $length != 0
80
-			? substr( $haystack, -$length ) === $needle
80
+			? substr($haystack, -$length) === $needle
81 81
 			: true;
82 82
 	}
83 83
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return void
89 89
 	 */
90
-	public function printTag( $tag, $value, array $attributes = [] )
90
+	public function printTag($tag, $value, array $attributes = [])
91 91
 	{
92
-		$attributes = $this->buildAttributesFor( $tag, $attributes );
92
+		$attributes = $this->buildAttributesFor($tag, $attributes);
93 93
 
94
-		printf( '<%s>%s</%s>',
95
-			rtrim( sprintf( '%s %s', $tag, $attributes )),
94
+		printf('<%s>%s</%s>',
95
+			rtrim(sprintf('%s %s', $tag, $attributes)),
96 96
 			$value,
97 97
 			$tag
98 98
 		);
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return string
107 107
 	 */
108
-	public function startWith( $prefix, $string, $unique = true )
108
+	public function startWith($prefix, $string, $unique = true)
109 109
 	{
110
-		return $unique && $this->startsWith( $prefix, $string )
110
+		return $unique && $this->startsWith($prefix, $string)
111 111
 			? $string
112 112
 			: $prefix . $string;
113 113
 	}
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return string
120 120
 	 */
121
-	public function startsWith( $needle, $haystack )
121
+	public function startsWith($needle, $haystack)
122 122
 	{
123
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
123
+		return substr($haystack, 0, strlen($needle)) === $needle;
124 124
 	}
125 125
 
126 126
 	/**
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return string
132 132
 	 */
133
-	public function trimLeft( $string, $needle, $caseSensitive = true )
133
+	public function trimLeft($string, $needle, $caseSensitive = true)
134 134
 	{
135 135
 		$strPos = $caseSensitive ? "strpos" : "stripos";
136
-		if( $strPos( $string, $needle ) === 0 ) {
137
-			$string = substr( $string, strlen( $needle ));
136
+		if ($strPos($string, $needle) === 0) {
137
+			$string = substr($string, strlen($needle));
138 138
 		}
139 139
 		return $string;
140 140
 	}
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	public function trimRight( $string, $needle, $caseSensitive = true )
149
+	public function trimRight($string, $needle, $caseSensitive = true)
150 150
 	{
151 151
 		$strPos = $caseSensitive ? "strpos" : "stripos";
152
-		if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle )) !== false ) {
153
-			$string = substr( $string, 0, -strlen( $needle ));
152
+		if ($strPos($string, $needle, strlen($string) - strlen($needle)) !== false) {
153
+			$string = substr($string, 0, -strlen($needle));
154 154
 		}
155 155
 		return $string;
156 156
 	}
Please login to merge, or discard this patch.
src/Helpers/Theme.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 {
9 9
 	public $postmeta;
10 10
 
11
-	public function __construct( PostMeta $postmeta )
11
+	public function __construct(PostMeta $postmeta)
12 12
 	{
13 13
 		$this->postmeta = $postmeta;
14 14
 	}
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string
20 20
 	 */
21
-	public function assetPath( $asset )
21
+	public function assetPath($asset)
22 22
 	{
23
-		return $this->paths( 'dir.stylesheet' ) . 'assets/' . $asset;
23
+		return $this->paths('dir.stylesheet') . 'assets/' . $asset;
24 24
 	}
25 25
 
26 26
 	/**
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return string
30 30
 	 */
31
-	public function assetUri( $asset )
31
+	public function assetUri($asset)
32 32
 	{
33
-		return $this->paths( 'uri.stylesheet' ) . 'assets/' . $asset;
33
+		return $this->paths('uri.stylesheet') . 'assets/' . $asset;
34 34
 	}
35 35
 
36 36
 	/**
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 			is_single(),
45 45
 		];
46 46
 
47
-		$display = in_array( true, $conditions );
47
+		$display = in_array(true, $conditions);
48 48
 
49
-		return apply_filters( 'castor/display/sidebar', $display );
49
+		return apply_filters('castor/display/sidebar', $display);
50 50
 	}
51 51
 
52 52
 	/**
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string
56 56
 	 */
57
-	public function imagePath( $asset )
57
+	public function imagePath($asset)
58 58
 	{
59
-		return $this->paths( 'dir.stylesheet' ) . 'assets/img/' . $asset;
59
+		return $this->paths('dir.stylesheet') . 'assets/img/' . $asset;
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string
66 66
 	 */
67
-	public function imageUri( $asset )
67
+	public function imageUri($asset)
68 68
 	{
69
-		return $this->paths( 'uri.stylesheet' ) . 'assets/img/' . $asset;
69
+		return $this->paths('uri.stylesheet') . 'assets/img/' . $asset;
70 70
 	}
71 71
 
72 72
 	public function pageTitle()
73 73
 	{
74
-		foreach( ['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool ) {
75
-			if( !$bool() )continue;
76
-			$method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool )));
74
+		foreach (['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool) {
75
+			if (!$bool())continue;
76
+			$method = sprintf('get%sTitle', ucfirst(str_replace('is_', '', $bool)));
77 77
 			return $this->$method();
78 78
 		}
79 79
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return array|string
87 87
 	 */
88
-	public function paths( $path = null )
88
+	public function paths($path = null)
89 89
 	{
90 90
 		$paths = [
91 91
 			'dir.stylesheet' => get_stylesheet_directory(),
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 			'uri.template'   => get_template_directory_uri(),
96 96
 		];
97 97
 
98
-		if( is_null( $path )) {
98
+		if (is_null($path)) {
99 99
 			return $paths;
100 100
 		}
101 101
 
102
-		return array_key_exists( $path, $paths )
103
-			? trailingslashit( $paths[$path] )
102
+		return array_key_exists($path, $paths)
103
+			? trailingslashit($paths[$path])
104 104
 			: '';
105 105
 	}
106 106
 
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string|null
111 111
 	 */
112
-	public function svg( $path = null )
112
+	public function svg($path = null)
113 113
 	{
114
-		if( $svg = file_get_contents( $this->imageUri( $path ))) {
114
+		if ($svg = file_get_contents($this->imageUri($path))) {
115 115
 			return $svg;
116 116
 		}
117 117
 	}
118 118
 
119 119
 	protected function get404Title()
120 120
 	{
121
-		return __( 'Not Found', 'castor' );
121
+		return __('Not Found', 'castor');
122 122
 	}
123 123
 
124 124
 	protected function getArchiveTitle()
@@ -128,20 +128,20 @@  discard block
 block discarded – undo
128 128
 
129 129
 	protected function getHomeTitle()
130 130
 	{
131
-		return ( $home = get_option( 'page_for_posts', true ))
132
-			? get_the_title( $home )
133
-			: __( 'Latest Posts', 'castor' );
131
+		return ($home = get_option('page_for_posts', true))
132
+			? get_the_title($home)
133
+			: __('Latest Posts', 'castor');
134 134
 	}
135 135
 
136 136
 	protected function getPageTitle()
137 137
 	{
138
-		return ($title = $this->postmeta->get( 'title' ))
138
+		return ($title = $this->postmeta->get('title'))
139 139
 			? $title
140 140
 			: get_the_title();
141 141
 	}
142 142
 
143 143
 	protected function getSearchTitle()
144 144
 	{
145
-		return sprintf( __( 'Search Results for %s', 'castor' ), get_search_query() );
145
+		return sprintf(__('Search Results for %s', 'castor'), get_search_query());
146 146
 	}
147 147
 }
Please login to merge, or discard this patch.
castor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1
-<?php defined( 'WPINC' ) || die;
1
+<?php defined('WPINC') || die;
2 2
 
3 3
 global $wp_version;
4 4
 
5
-if( version_compare( '5.6.0', phpversion(), '>=' )) {
5
+if (version_compare('5.6.0', phpversion(), '>=')) {
6 6
 	wp_die(
7
-		__( 'You must be using PHP 5.6.0 or greater.', 'castor' ),
8
-		__( 'Unsupported PHP version', 'castor' )
7
+		__('You must be using PHP 5.6.0 or greater.', 'castor'),
8
+		__('Unsupported PHP version', 'castor')
9 9
 	);
10 10
 }
11 11
 
12
-if( version_compare( '4.7.0', $wp_version, '>=' )) {
12
+if (version_compare('4.7.0', $wp_version, '>=')) {
13 13
 	wp_die(
14
-		__( 'You must be using WordPress 4.7.0 or greater.', 'castor' ),
15
-		__( 'Unsupported WordPress version', 'castor' )
14
+		__('You must be using WordPress 4.7.0 or greater.', 'castor'),
15
+		__('Unsupported WordPress version', 'castor')
16 16
 	);
17 17
 }
18 18
 
19
-if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) {
19
+if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) {
20 20
 	wp_die(
21
-		__( 'Theme must be activated prior to using the customizer.', 'castor' )
21
+		__('Theme must be activated prior to using the customizer.', 'castor')
22 22
 	);
23 23
 }
24 24
 
25
-require_once( ABSPATH . '/' . WPINC . '/class-oembed.php' );
25
+require_once(ABSPATH . '/' . WPINC . '/class-oembed.php');
26 26
 
27 27
 \GeminiLabs\Castor\Application::getInstance()->init();
Please login to merge, or discard this patch.
src/Gallery.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	protected $theme;
20 20
 	protected $utility;
21 21
 
22
-	public function __construct( Image $image, PostMeta $postmeta, Theme $theme, Utility $utility )
22
+	public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility)
23 23
 	{
24 24
 		$this->image    = $image;
25 25
 		$this->postmeta = $postmeta;
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @return WP_Query
32 32
 	 */
33
-	public function get( array $args = [] )
33
+	public function get(array $args = [])
34 34
 	{
35
-		$this->normalizeArgs( $args );
35
+		$this->normalizeArgs($args);
36 36
 
37 37
 		$this->gallery = new WP_Query([
38 38
 			'orderby'        => 'post__in',
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function render()
54 54
 	{
55
-		$images = array_reduce( $this->gallery->posts, function( $images, $attachment ) {
56
-			return $images . $this->renderImage( $attachment );
55
+		$images = array_reduce($this->gallery->posts, function($images, $attachment) {
56
+			return $images . $this->renderImage($attachment);
57 57
 		});
58
-		return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>', $images );
58
+		return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>', $images);
59 59
 	}
60 60
 
61 61
 	/**
62 62
 	 * @return null|string
63 63
 	 */
64
-	public function renderImage( WP_Post $attachment )
64
+	public function renderImage(WP_Post $attachment)
65 65
 	{
66
-		$image = $this->image->get( $attachment->ID )->image;
66
+		$image = $this->image->get($attachment->ID)->image;
67 67
 
68
-		if( !$image )return;
68
+		if (!$image)return;
69 69
 		return sprintf(
70 70
 			'<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' .
71 71
 				'%s<figcaption itemprop="caption description">' .
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 			'</figure>',
75 75
 			$image->thumbnail['width'],
76 76
 			$image->thumbnail['height'],
77
-			$this->getPhotoswipeData( $image ),
78
-			$this->renderImageTag( $image ),
77
+			$this->getPhotoswipeData($image),
78
+			$this->renderImageTag($image),
79 79
 			$image->caption,
80 80
 			$image->copyright
81 81
 		);
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function renderPagination()
88 88
 	{
89
-		if( !$this->args['pagination'] )return;
89
+		if (!$this->args['pagination'])return;
90 90
 		return paginate_links([
91
-			'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>',
91
+			'before_page_number' => '<span class="screen-reader-text">' . __('Page', 'castor') . ' </span>',
92 92
 			'current'            => $this->gallery->query['paged'],
93 93
 			'mid_size'           => 1,
94
-			'next_text'          => __( 'Next', 'castor' ),
95
-			'prev_text'          => __( 'Previous', 'castor' ),
94
+			'next_text'          => __('Next', 'castor'),
95
+			'prev_text'          => __('Previous', 'castor'),
96 96
 			'total'              => $this->gallery->max_num_pages,
97 97
 		]);
98 98
 	}
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return bool
105 105
 	 */
106
-	protected function getBoolValue( $key, $value = null )
106
+	protected function getBoolValue($key, $value = null)
107 107
 	{
108
-		$bool = $this->getValue( $key, $value );
108
+		$bool = $this->getValue($key, $value);
109 109
 
110
-		if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ))) {
111
-			$bool = $this->postmeta->get( $bool );
110
+		if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) {
111
+			$bool = $this->postmeta->get($bool);
112 112
 		}
113
-		return wp_validate_boolean( $bool );
113
+		return wp_validate_boolean($bool);
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return int
120 120
 	 */
121
-	protected function getGalleryArg( $value = null )
121
+	protected function getGalleryArg($value = null)
122 122
 	{
123
-		$gallery = $this->getValue( 'gallery', $value );
123
+		$gallery = $this->getValue('gallery', $value);
124 124
 
125
-		if( !is_numeric( $gallery ) && is_string( $gallery )) {
126
-			$gallery = intval( $this->postmeta->get( $gallery ));
125
+		if (!is_numeric($gallery) && is_string($gallery)) {
126
+			$gallery = intval($this->postmeta->get($gallery));
127 127
 		}
128
-		return !is_null( get_post( $gallery ))
129
-			? intval( $gallery )
128
+		return !is_null(get_post($gallery))
129
+			? intval($gallery)
130 130
 			: 0;
131 131
 	}
132 132
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return int
137 137
 	 */
138
-	protected function getImagesPerPageArg( $value = null )
138
+	protected function getImagesPerPageArg($value = null)
139 139
 	{
140
-		$perPage = $this->getValue( 'images_per_page', $value );
140
+		$perPage = $this->getValue('images_per_page', $value);
141 141
 
142
-		if( !is_numeric( $perPage ) && is_string( $perPage )) {
143
-			$perPage = $this->postmeta->get( $perPage );
142
+		if (!is_numeric($perPage) && is_string($perPage)) {
143
+			$perPage = $this->postmeta->get($perPage);
144 144
 		}
145
-		return !!intval( $perPage )
145
+		return !!intval($perPage)
146 146
 			? $perPage
147 147
 			: -1;
148 148
 	}
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return bool
154 154
 	 */
155
-	protected function getLazyloadArg( $value = null )
155
+	protected function getLazyloadArg($value = null)
156 156
 	{
157
-		return $this->getBoolValue( 'lazyload', $value );
157
+		return $this->getBoolValue('lazyload', $value);
158 158
 	}
159 159
 
160 160
 	/**
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return array
164 164
 	 */
165
-	protected function getMediaArg( $value = null )
165
+	protected function getMediaArg($value = null)
166 166
 	{
167
-		$media = $this->getValue( 'media', $value );
167
+		$media = $this->getValue('media', $value);
168 168
 
169
-		if( is_string( $media )) {
170
-			$media = $this->postmeta->get( $media, [
169
+		if (is_string($media)) {
170
+			$media = $this->postmeta->get($media, [
171 171
 				'ID'     => $this->getGalleryArg(),
172 172
 				'single' => false,
173 173
 			]);
174 174
 		}
175
-		return is_array( $media )
176
-			? wp_parse_id_list( $media )
175
+		return is_array($media)
176
+			? wp_parse_id_list($media)
177 177
 			: [];
178 178
 	}
179 179
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	protected function getPaged()
184 184
 	{
185
-		return intval( get_query_var(( is_front_page() ? 'page' : 'paged' ))) ?: 1;
185
+		return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1;
186 186
 	}
187 187
 
188 188
 	/**
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return bool
192 192
 	 */
193
-	protected function getPaginationArg( $value = null )
193
+	protected function getPaginationArg($value = null)
194 194
 	{
195
-		return $this->getBoolValue( 'pagination', $value );
195
+		return $this->getBoolValue('pagination', $value);
196 196
 	}
197 197
 
198 198
 	/**
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return bool
202 202
 	 */
203
-	protected function getPermalinksArg( $value = null )
203
+	protected function getPermalinksArg($value = null)
204 204
 	{
205
-		return $this->getBoolValue( 'permalinks', $value );
205
+		return $this->getBoolValue('permalinks', $value);
206 206
 	}
207 207
 
208 208
 	/**
209 209
 	 * @return string
210 210
 	 */
211
-	protected function getPhotoswipeData( $image )
211
+	protected function getPhotoswipeData($image)
212 212
 	{
213
-		return sprintf( '{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
213
+		return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
214 214
 			$image->large['url'],
215 215
 			$image->large['width'],
216 216
 			$image->large['height'],
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return mixed
228 228
 	 */
229
-	protected function getValue( $key, $value = null )
229
+	protected function getValue($key, $value = null)
230 230
 	{
231
-		if( is_null( $value ) && isset( $this->args[$key] )) {
231
+		if (is_null($value) && isset($this->args[$key])) {
232 232
 			$value = $this->args[$key];
233 233
 		}
234 234
 		return $value;
@@ -237,23 +237,23 @@  discard block
 block discarded – undo
237 237
 	/**
238 238
 	 * @return array
239 239
 	 */
240
-	protected function normalizeArgs( array $args = [] )
240
+	protected function normalizeArgs(array $args = [])
241 241
 	{
242 242
 		$defaults = [
243
-			'gallery',         // (string) meta_key | (int) post_id
244
-			'lazyload',        // (string) meta_key | (bool)
245
-			'media',           // (string) meta_key | (array) post_ids
246
-			'pagination',      // (string) meta_key | (bool)
243
+			'gallery', // (string) meta_key | (int) post_id
244
+			'lazyload', // (string) meta_key | (bool)
245
+			'media', // (string) meta_key | (array) post_ids
246
+			'pagination', // (string) meta_key | (bool)
247 247
 			'images_per_page', // (string) meta_key | (int) number
248
-			'permalinks',      // (string) meta_key | (bool)
248
+			'permalinks', // (string) meta_key | (bool)
249 249
 		];
250 250
 
251
-		$this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args );
251
+		$this->args = shortcode_atts(array_combine($defaults, $defaults), $args);
252 252
 
253
-		array_walk( $this->args, function( &$value, $key ) {
254
-			$method = $this->utility->buildMethodName( $key . '_arg' );
255
-			if( method_exists( $this, $method )) {
256
-				$value = call_user_func([ $this, $method ], $value );
253
+		array_walk($this->args, function(&$value, $key) {
254
+			$method = $this->utility->buildMethodName($key . '_arg');
255
+			if (method_exists($this, $method)) {
256
+				$value = call_user_func([$this, $method], $value);
257 257
 			}
258 258
 		});
259 259
 
@@ -265,20 +265,20 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return null|string
267 267
 	 */
268
-	protected function renderImageTag( $image )
268
+	protected function renderImageTag($image)
269 269
 	{
270 270
 		$imgSrc = $this->getLazyloadArg()
271
-			? $this->theme->imageUri( 'blank.gif' )
271
+			? $this->theme->imageUri('blank.gif')
272 272
 			: $image->thumbnail['url'];
273 273
 
274
-		$imgTag = sprintf( '<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
274
+		$imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
275 275
 			$imgSrc,
276 276
 			$image->thumbnail['url'],
277 277
 			$image->alt
278 278
 		);
279 279
 
280 280
 		return $this->getPermalinksArg()
281
-			? sprintf( '<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag )
281
+			? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag)
282 282
 			: $imgTag;
283 283
 	}
284 284
 }
Please login to merge, or discard this patch.