Passed
Push — develop ( 9bfb1a...51b9ff )
by Paul
03:13
created
src/Exceptions/BindingResolutionException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,6 +4,5 @@
 block discarded – undo
4 4
 
5 5
 use Exception;
6 6
 
7
-class BindingResolutionException extends Exception
8
-{
7
+class BindingResolutionException extends Exception {
9 8
 }
Please login to merge, or discard this patch.
templates/email/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 <html>
3 3
 <head>
4 4
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
-    <title><?= wp_specialchars_decode((string) get_option('blogname'), ENT_QUOTES); ?></title>
5
+    <title><?= wp_specialchars_decode( (string) get_option( 'blogname' ), ENT_QUOTES ); ?></title>
6 6
 </head>
7 7
 <body>
8 8
 
Please login to merge, or discard this patch.
src/Image.php 3 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -7,80 +7,80 @@
 block discarded – undo
7 7
 
8 8
 class Image
9 9
 {
10
-    public $image;
10
+	public $image;
11 11
 
12
-    protected $postmeta;
13
-    protected $utility;
12
+	protected $postmeta;
13
+	protected $utility;
14 14
 
15
-    public function __construct(PostMeta $postmeta, Utility $utility)
16
-    {
17
-        $this->postmeta = $postmeta;
18
-        $this->utility = $utility;
19
-    }
15
+	public function __construct(PostMeta $postmeta, Utility $utility)
16
+	{
17
+		$this->postmeta = $postmeta;
18
+		$this->utility = $utility;
19
+	}
20 20
 
21
-    /**
22
-     * @param int|string $attachment
23
-     *
24
-     * @return self
25
-     */
26
-    public function get($attachment)
27
-    {
28
-        $attachment = $this->normalize($attachment);
29
-        if ($attachment && $thumbnail = wp_get_attachment_image_src($attachment, 'thumbnail')) {
30
-            $medium = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'medium'), $thumbnail);
31
-            $large = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'large'), $medium);
21
+	/**
22
+	 * @param int|string $attachment
23
+	 *
24
+	 * @return self
25
+	 */
26
+	public function get($attachment)
27
+	{
28
+		$attachment = $this->normalize($attachment);
29
+		if ($attachment && $thumbnail = wp_get_attachment_image_src($attachment, 'thumbnail')) {
30
+			$medium = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'medium'), $thumbnail);
31
+			$large = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'large'), $medium);
32 32
 
33
-            $this->image = (object) [
34
-                'alt' => wp_strip_all_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true), true),
35
-                'caption' => wp_get_attachment_caption($attachment),
36
-                'copyright' => wp_strip_all_tags(get_post_meta($attachment, '_copyright', true), true),
37
-                'ID' => $attachment,
38
-                'large' => $large,
39
-                'medium' => $medium,
40
-                'permalink' => get_attachment_link($attachment),
41
-                'thumbnail' => $this->normalizeSrc($thumbnail),
42
-            ];
43
-        }
44
-        return $this;
45
-    }
33
+			$this->image = (object) [
34
+				'alt' => wp_strip_all_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true), true),
35
+				'caption' => wp_get_attachment_caption($attachment),
36
+				'copyright' => wp_strip_all_tags(get_post_meta($attachment, '_copyright', true), true),
37
+				'ID' => $attachment,
38
+				'large' => $large,
39
+				'medium' => $medium,
40
+				'permalink' => get_attachment_link($attachment),
41
+				'thumbnail' => $this->normalizeSrc($thumbnail),
42
+			];
43
+		}
44
+		return $this;
45
+	}
46 46
 
47
-    public function render($size = 'large')
48
-    {
49
-        if ($this->image) {
50
-            return wp_get_attachment_image($this->image->ID, $size);
51
-        }
52
-    }
47
+	public function render($size = 'large')
48
+	{
49
+		if ($this->image) {
50
+			return wp_get_attachment_image($this->image->ID, $size);
51
+		}
52
+	}
53 53
 
54
-    protected function normalize($attachmentId)
55
-    {
56
-        if (!filter_var($attachmentId, FILTER_VALIDATE_INT)) {
57
-            $attachmentId = $this->postmeta->get($attachmentId);
58
-        }
54
+	protected function normalize($attachmentId)
55
+	{
56
+		if (!filter_var($attachmentId, FILTER_VALIDATE_INT)) {
57
+			$attachmentId = $this->postmeta->get($attachmentId);
58
+		}
59 59
 
60
-        $attachment = get_post($attachmentId);
60
+		$attachment = get_post($attachmentId);
61 61
 
62
-        if (is_null($attachment) || 'attachment' != $attachment->post_type) {
63
-            return;
64
-        }
62
+		if (is_null($attachment) || 'attachment' != $attachment->post_type) {
63
+			return;
64
+		}
65 65
 
66
-        return $attachment->ID;
67
-    }
66
+		return $attachment->ID;
67
+	}
68 68
 
69
-    /**
70
-     * @param mixed $fallback
71
-     *
72
-     * @return array
73
-     */
74
-    protected function normalizeSrc(array $image, $fallback = false)
75
-    {
76
-        if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) {
77
-            $image = $fallback;
78
-        }
79
-        $image = array_pad($image, 3, '');
80
-        return [
81
-            'url' => array_shift($image),
82
-            'width' => array_shift($image),
83
-            'height' => array_shift($image),
84
-        ];
85
-    }
69
+	/**
70
+	 * @param mixed $fallback
71
+	 *
72
+	 * @return array
73
+	 */
74
+	protected function normalizeSrc(array $image, $fallback = false)
75
+	{
76
+		if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) {
77
+			$image = $fallback;
78
+		}
79
+		$image = array_pad($image, 3, '');
80
+		return [
81
+			'url' => array_shift($image),
82
+			'width' => array_shift($image),
83
+			'height' => array_shift($image),
84
+		];
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     protected $postmeta;
13 13
     protected $utility;
14 14
 
15
-    public function __construct(PostMeta $postmeta, Utility $utility)
15
+    public function __construct( PostMeta $postmeta, Utility $utility )
16 16
     {
17 17
         $this->postmeta = $postmeta;
18 18
         $this->utility = $utility;
@@ -23,43 +23,43 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @return self
25 25
      */
26
-    public function get($attachment)
26
+    public function get( $attachment )
27 27
     {
28
-        $attachment = $this->normalize($attachment);
29
-        if ($attachment && $thumbnail = wp_get_attachment_image_src($attachment, 'thumbnail')) {
30
-            $medium = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'medium'), $thumbnail);
31
-            $large = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'large'), $medium);
28
+        $attachment = $this->normalize( $attachment );
29
+        if( $attachment && $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' ) ) {
30
+            $medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail );
31
+            $large = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'large' ), $medium );
32 32
 
33 33
             $this->image = (object) [
34
-                'alt' => wp_strip_all_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true), true),
35
-                'caption' => wp_get_attachment_caption($attachment),
36
-                'copyright' => wp_strip_all_tags(get_post_meta($attachment, '_copyright', true), true),
34
+                'alt' => wp_strip_all_tags( get_post_meta( $attachment, '_wp_attachment_image_alt', true ), true ),
35
+                'caption' => wp_get_attachment_caption( $attachment ),
36
+                'copyright' => wp_strip_all_tags( get_post_meta( $attachment, '_copyright', true ), true ),
37 37
                 'ID' => $attachment,
38 38
                 'large' => $large,
39 39
                 'medium' => $medium,
40
-                'permalink' => get_attachment_link($attachment),
41
-                'thumbnail' => $this->normalizeSrc($thumbnail),
40
+                'permalink' => get_attachment_link( $attachment ),
41
+                'thumbnail' => $this->normalizeSrc( $thumbnail ),
42 42
             ];
43 43
         }
44 44
         return $this;
45 45
     }
46 46
 
47
-    public function render($size = 'large')
47
+    public function render( $size = 'large' )
48 48
     {
49
-        if ($this->image) {
50
-            return wp_get_attachment_image($this->image->ID, $size);
49
+        if( $this->image ) {
50
+            return wp_get_attachment_image( $this->image->ID, $size );
51 51
         }
52 52
     }
53 53
 
54
-    protected function normalize($attachmentId)
54
+    protected function normalize( $attachmentId )
55 55
     {
56
-        if (!filter_var($attachmentId, FILTER_VALIDATE_INT)) {
57
-            $attachmentId = $this->postmeta->get($attachmentId);
56
+        if( !filter_var( $attachmentId, FILTER_VALIDATE_INT ) ) {
57
+            $attachmentId = $this->postmeta->get( $attachmentId );
58 58
         }
59 59
 
60
-        $attachment = get_post($attachmentId);
60
+        $attachment = get_post( $attachmentId );
61 61
 
62
-        if (is_null($attachment) || 'attachment' != $attachment->post_type) {
62
+        if( is_null( $attachment ) || 'attachment' != $attachment->post_type ) {
63 63
             return;
64 64
         }
65 65
 
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return array
73 73
      */
74
-    protected function normalizeSrc(array $image, $fallback = false)
74
+    protected function normalizeSrc( array $image, $fallback = false )
75 75
     {
76
-        if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) {
76
+        if( is_array( $fallback ) && count( array_diff( $image, $fallback ) ) < 2 ) {
77 77
             $image = $fallback;
78 78
         }
79
-        $image = array_pad($image, 3, '');
79
+        $image = array_pad( $image, 3, '' );
80 80
         return [
81
-            'url' => array_shift($image),
82
-            'width' => array_shift($image),
83
-            'height' => array_shift($image),
81
+            'url' => array_shift( $image ),
82
+            'width' => array_shift( $image ),
83
+            'height' => array_shift( $image ),
84 84
         ];
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use GeminiLabs\Castor\Helpers\PostMeta;
6 6
 use GeminiLabs\Castor\Helpers\Utility;
7 7
 
8
-class Image
9
-{
8
+class Image {
10 9
     public $image;
11 10
 
12 11
     protected $postmeta;
Please login to merge, or discard this patch.
src/Facade.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -6,109 +6,109 @@
 block discarded – undo
6 6
 
7 7
 abstract class Facade
8 8
 {
9
-    /**
10
-     * The application instance being facaded.
11
-     *
12
-     * @var Application
13
-     */
14
-    protected static $app;
9
+	/**
10
+	 * The application instance being facaded.
11
+	 *
12
+	 * @var Application
13
+	 */
14
+	protected static $app;
15 15
 
16
-    /**
17
-     * The resolved object instances.
18
-     *
19
-     * @var array
20
-     */
21
-    protected static $resolvedInstance;
16
+	/**
17
+	 * The resolved object instances.
18
+	 *
19
+	 * @var array
20
+	 */
21
+	protected static $resolvedInstance;
22 22
 
23
-    /**
24
-     * Handle dynamic, static calls to the object.
25
-     *
26
-     * @param string $method
27
-     * @param array  $args
28
-     *
29
-     * @return mixed
30
-     * @throws \RuntimeException
31
-     */
32
-    public static function __callStatic($method, $args)
33
-    {
34
-        $instance = static::getFacadeRoot();
23
+	/**
24
+	 * Handle dynamic, static calls to the object.
25
+	 *
26
+	 * @param string $method
27
+	 * @param array  $args
28
+	 *
29
+	 * @return mixed
30
+	 * @throws \RuntimeException
31
+	 */
32
+	public static function __callStatic($method, $args)
33
+	{
34
+		$instance = static::getFacadeRoot();
35 35
 
36
-        if (!$instance) {
37
-            throw new RuntimeException('A facade root has not been set.');
38
-        }
36
+		if (!$instance) {
37
+			throw new RuntimeException('A facade root has not been set.');
38
+		}
39 39
 
40
-        return $instance->$method(...$args);
41
-    }
40
+		return $instance->$method(...$args);
41
+	}
42 42
 
43
-    /**
44
-     * Clear all of the resolved instances.
45
-     *
46
-     * @return void
47
-     */
48
-    public static function clearResolvedInstances()
49
-    {
50
-        static::$resolvedInstance = [];
51
-    }
43
+	/**
44
+	 * Clear all of the resolved instances.
45
+	 *
46
+	 * @return void
47
+	 */
48
+	public static function clearResolvedInstances()
49
+	{
50
+		static::$resolvedInstance = [];
51
+	}
52 52
 
53
-    /**
54
-     * Get the application instance behind the facade.
55
-     *
56
-     * @return Application
57
-     */
58
-    public static function getFacadeApplication()
59
-    {
60
-        return static::$app;
61
-    }
53
+	/**
54
+	 * Get the application instance behind the facade.
55
+	 *
56
+	 * @return Application
57
+	 */
58
+	public static function getFacadeApplication()
59
+	{
60
+		return static::$app;
61
+	}
62 62
 
63
-    /**
64
-     * Get the root object behind the facade.
65
-     *
66
-     * @return mixed
67
-     */
68
-    public static function getFacadeRoot()
69
-    {
70
-        return static::resolveFacadeInstance(static::getFacadeAccessor());
71
-    }
63
+	/**
64
+	 * Get the root object behind the facade.
65
+	 *
66
+	 * @return mixed
67
+	 */
68
+	public static function getFacadeRoot()
69
+	{
70
+		return static::resolveFacadeInstance(static::getFacadeAccessor());
71
+	}
72 72
 
73
-    /**
74
-     * Set the application instance.
75
-     *
76
-     * @return void
77
-     */
78
-    public static function setFacadeApplication(Application $app)
79
-    {
80
-        static::$app = $app;
81
-    }
73
+	/**
74
+	 * Set the application instance.
75
+	 *
76
+	 * @return void
77
+	 */
78
+	public static function setFacadeApplication(Application $app)
79
+	{
80
+		static::$app = $app;
81
+	}
82 82
 
83
-    /**
84
-     * Get the registered name of the component.
85
-     *
86
-     * @return string
87
-     *
88
-     * @throws \RuntimeException
89
-     */
90
-    protected static function getFacadeAccessor()
91
-    {
92
-        throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
93
-    }
83
+	/**
84
+	 * Get the registered name of the component.
85
+	 *
86
+	 * @return string
87
+	 *
88
+	 * @throws \RuntimeException
89
+	 */
90
+	protected static function getFacadeAccessor()
91
+	{
92
+		throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
93
+	}
94 94
 
95
-    /**
96
-     * Resolve the facade root instance from the container.
97
-     *
98
-     * @param string|object $name
99
-     *
100
-     * @return mixed
101
-     */
102
-    protected static function resolveFacadeInstance($name)
103
-    {
104
-        if (is_object($name)) {
105
-            return $name;
106
-        }
95
+	/**
96
+	 * Resolve the facade root instance from the container.
97
+	 *
98
+	 * @param string|object $name
99
+	 *
100
+	 * @return mixed
101
+	 */
102
+	protected static function resolveFacadeInstance($name)
103
+	{
104
+		if (is_object($name)) {
105
+			return $name;
106
+		}
107 107
 
108
-        if (isset(static::$resolvedInstance[$name])) {
109
-            return static::$resolvedInstance[$name];
110
-        }
108
+		if (isset(static::$resolvedInstance[$name])) {
109
+			return static::$resolvedInstance[$name];
110
+		}
111 111
 
112
-        return static::$resolvedInstance[$name] = static::$app->make($name);
113
-    }
112
+		return static::$resolvedInstance[$name] = static::$app->make($name);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
      * @return mixed
30 30
      * @throws \RuntimeException
31 31
      */
32
-    public static function __callStatic($method, $args)
32
+    public static function __callStatic( $method, $args )
33 33
     {
34 34
         $instance = static::getFacadeRoot();
35 35
 
36
-        if (!$instance) {
37
-            throw new RuntimeException('A facade root has not been set.');
36
+        if( !$instance ) {
37
+            throw new RuntimeException( 'A facade root has not been set.' );
38 38
         }
39 39
 
40
-        return $instance->$method(...$args);
40
+        return $instance->$method( ...$args );
41 41
     }
42 42
 
43 43
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public static function getFacadeRoot()
69 69
     {
70
-        return static::resolveFacadeInstance(static::getFacadeAccessor());
70
+        return static::resolveFacadeInstance( static::getFacadeAccessor() );
71 71
     }
72 72
 
73 73
     /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      *
76 76
      * @return void
77 77
      */
78
-    public static function setFacadeApplication(Application $app)
78
+    public static function setFacadeApplication( Application $app )
79 79
     {
80 80
         static::$app = $app;
81 81
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected static function getFacadeAccessor()
91 91
     {
92
-        throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
92
+        throw new RuntimeException( 'Facade does not implement getFacadeAccessor method.' );
93 93
     }
94 94
 
95 95
     /**
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
      *
100 100
      * @return mixed
101 101
      */
102
-    protected static function resolveFacadeInstance($name)
102
+    protected static function resolveFacadeInstance( $name )
103 103
     {
104
-        if (is_object($name)) {
104
+        if( is_object( $name ) ) {
105 105
             return $name;
106 106
         }
107 107
 
108
-        if (isset(static::$resolvedInstance[$name])) {
108
+        if( isset( static::$resolvedInstance[$name] ) ) {
109 109
             return static::$resolvedInstance[$name];
110 110
         }
111 111
 
112
-        return static::$resolvedInstance[$name] = static::$app->make($name);
112
+        return static::$resolvedInstance[$name] = static::$app->make( $name );
113 113
     }
114 114
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use RuntimeException;
6 6
 
7
-abstract class Facade
8
-{
7
+abstract class Facade {
9 8
     /**
10 9
      * The application instance being facaded.
11 10
      *
Please login to merge, or discard this patch.
src/Container.php 3 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -9,213 +9,213 @@
 block discarded – undo
9 9
 
10 10
 abstract class Container
11 11
 {
12
-    /**
13
-     * The current globally available container (if any).
14
-     *
15
-     * @var static
16
-     */
17
-    protected static $instance;
18
-
19
-    /**
20
-     * The container's bound services.
21
-     *
22
-     * @var array
23
-     */
24
-    protected $services = [];
25
-
26
-    /**
27
-     * The container's bucket items.
28
-     *
29
-     * @var array
30
-     */
31
-    protected $bucket = [];
32
-
33
-    /**
34
-     * Set the globally available instance of the container.
35
-     *
36
-     * @return static
37
-     */
38
-    public static function getInstance()
39
-    {
40
-        if (is_null(static::$instance)) {
41
-            static::$instance = new static();
42
-        }
43
-
44
-        return static::$instance;
45
-    }
46
-
47
-    /**
48
-     * Bind a service to the container.
49
-     *
50
-     * @param string $alias
51
-     * @param mixed  $concrete
52
-     *
53
-     * @return mixed
54
-     */
55
-    public function bind($alias, $concrete)
56
-    {
57
-        $this->services[$alias] = $concrete;
58
-    }
59
-
60
-    /**
61
-     * Resolve the given type from the container.
62
-     * Allow unbound aliases that omit the root namespace
63
-     * i.e. 'Controller' translates to 'GeminiLabs\Castor\Controller'.
64
-     *
65
-     * @param mixed $abstract
66
-     *
67
-     * @return mixed
68
-     */
69
-    public function make($abstract)
70
-    {
71
-        $service = isset($this->services[$abstract])
72
-            ? $this->services[$abstract]
73
-            : $this->addNamespace($abstract);
74
-
75
-        if (is_callable($service)) {
76
-            return call_user_func_array($service, [$this]);
77
-        }
78
-        if (is_object($service)) {
79
-            return $service;
80
-        }
81
-
82
-        return $this->resolve($service);
83
-    }
84
-
85
-    /**
86
-     * Register a shared binding in the container.
87
-     *
88
-     * @param string               $abstract
89
-     * @param \Closure|string|null $concrete
90
-     *
91
-     * @return void
92
-     */
93
-    public function singleton($abstract, $concrete)
94
-    {
95
-        $this->bind($abstract, $this->make($concrete));
96
-    }
97
-
98
-    /**
99
-     * Dynamically access container bucket items.
100
-     *
101
-     * @param string $item
102
-     *
103
-     * @return mixed
104
-     */
105
-    public function __get($item)
106
-    {
107
-        return isset($this->bucket[$item])
108
-            ? $this->bucket[$item]
109
-            : null;
110
-    }
111
-
112
-    /**
113
-     * Dynamically set container bucket items.
114
-     *
115
-     * @param string $item
116
-     * @param mixed  $value
117
-     *
118
-     * @return void
119
-     */
120
-    public function __set($item, $value)
121
-    {
122
-        $this->bucket[$item] = $value;
123
-    }
124
-
125
-    /**
126
-     * Prefix the current namespace to the abstract if absent.
127
-     *
128
-     * @param string $abstract
129
-     *
130
-     * @return string
131
-     */
132
-    protected function addNamespace($abstract)
133
-    {
134
-        if (false === strpos($abstract, __NAMESPACE__) && !class_exists($abstract)) {
135
-            $abstract = __NAMESPACE__."\\$abstract";
136
-        }
137
-
138
-        return $abstract;
139
-    }
140
-
141
-    /**
142
-     * Throw an exception that the concrete is not instantiable.
143
-     *
144
-     * @param string $concrete
145
-     *
146
-     * @return void
147
-     * @throws BindingResolutionException
148
-     */
149
-    protected function notInstantiable($concrete)
150
-    {
151
-        $message = "Target [$concrete] is not instantiable.";
152
-
153
-        throw new BindingResolutionException($message);
154
-    }
155
-
156
-    /**
157
-     * Resolve a class based dependency from the container.
158
-     *
159
-     * @param mixed $concrete
160
-     *
161
-     * @return mixed
162
-     * @throws BindingResolutionException
163
-     */
164
-    protected function resolve($concrete)
165
-    {
166
-        if ($concrete instanceof Closure) {
167
-            return $concrete($this);
168
-        }
169
-
170
-        $reflector = new ReflectionClass($concrete);
171
-
172
-        if (!$reflector->isInstantiable()) {
173
-            return $this->notInstantiable($concrete);
174
-        }
175
-
176
-        if (is_null(($constructor = $reflector->getConstructor()))) {
177
-            return new $concrete();
178
-        }
179
-
180
-        return $reflector->newInstanceArgs(
181
-            $this->resolveDependencies($constructor->getParameters())
182
-        );
183
-    }
184
-
185
-    /**
186
-     * Resolve a class based dependency from the container.
187
-     *
188
-     * @return mixed
189
-     * @throws BindingResolutionException
190
-     */
191
-    protected function resolveClass(ReflectionParameter $parameter)
192
-    {
193
-        try {
194
-            return $this->make($parameter->getClass()->name);
195
-        } catch (BindingResolutionException $e) {
196
-            if ($parameter->isOptional()) {
197
-                return $parameter->getDefaultValue();
198
-            }
199
-            throw $e;
200
-        }
201
-    }
202
-
203
-    /**
204
-     * Resolve all of the dependencies from the ReflectionParameters.
205
-     *
206
-     * @return array
207
-     */
208
-    protected function resolveDependencies(array $dependencies)
209
-    {
210
-        $results = [];
211
-
212
-        foreach ($dependencies as $dependency) {
213
-            // If the class is null, the dependency is a string or some other primitive type
214
-            $results[] = !is_null($class = $dependency->getClass())
215
-                ? $this->resolveClass($dependency)
216
-                : null;
217
-        }
218
-
219
-        return $results;
220
-    }
12
+	/**
13
+	 * The current globally available container (if any).
14
+	 *
15
+	 * @var static
16
+	 */
17
+	protected static $instance;
18
+
19
+	/**
20
+	 * The container's bound services.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $services = [];
25
+
26
+	/**
27
+	 * The container's bucket items.
28
+	 *
29
+	 * @var array
30
+	 */
31
+	protected $bucket = [];
32
+
33
+	/**
34
+	 * Set the globally available instance of the container.
35
+	 *
36
+	 * @return static
37
+	 */
38
+	public static function getInstance()
39
+	{
40
+		if (is_null(static::$instance)) {
41
+			static::$instance = new static();
42
+		}
43
+
44
+		return static::$instance;
45
+	}
46
+
47
+	/**
48
+	 * Bind a service to the container.
49
+	 *
50
+	 * @param string $alias
51
+	 * @param mixed  $concrete
52
+	 *
53
+	 * @return mixed
54
+	 */
55
+	public function bind($alias, $concrete)
56
+	{
57
+		$this->services[$alias] = $concrete;
58
+	}
59
+
60
+	/**
61
+	 * Resolve the given type from the container.
62
+	 * Allow unbound aliases that omit the root namespace
63
+	 * i.e. 'Controller' translates to 'GeminiLabs\Castor\Controller'.
64
+	 *
65
+	 * @param mixed $abstract
66
+	 *
67
+	 * @return mixed
68
+	 */
69
+	public function make($abstract)
70
+	{
71
+		$service = isset($this->services[$abstract])
72
+			? $this->services[$abstract]
73
+			: $this->addNamespace($abstract);
74
+
75
+		if (is_callable($service)) {
76
+			return call_user_func_array($service, [$this]);
77
+		}
78
+		if (is_object($service)) {
79
+			return $service;
80
+		}
81
+
82
+		return $this->resolve($service);
83
+	}
84
+
85
+	/**
86
+	 * Register a shared binding in the container.
87
+	 *
88
+	 * @param string               $abstract
89
+	 * @param \Closure|string|null $concrete
90
+	 *
91
+	 * @return void
92
+	 */
93
+	public function singleton($abstract, $concrete)
94
+	{
95
+		$this->bind($abstract, $this->make($concrete));
96
+	}
97
+
98
+	/**
99
+	 * Dynamically access container bucket items.
100
+	 *
101
+	 * @param string $item
102
+	 *
103
+	 * @return mixed
104
+	 */
105
+	public function __get($item)
106
+	{
107
+		return isset($this->bucket[$item])
108
+			? $this->bucket[$item]
109
+			: null;
110
+	}
111
+
112
+	/**
113
+	 * Dynamically set container bucket items.
114
+	 *
115
+	 * @param string $item
116
+	 * @param mixed  $value
117
+	 *
118
+	 * @return void
119
+	 */
120
+	public function __set($item, $value)
121
+	{
122
+		$this->bucket[$item] = $value;
123
+	}
124
+
125
+	/**
126
+	 * Prefix the current namespace to the abstract if absent.
127
+	 *
128
+	 * @param string $abstract
129
+	 *
130
+	 * @return string
131
+	 */
132
+	protected function addNamespace($abstract)
133
+	{
134
+		if (false === strpos($abstract, __NAMESPACE__) && !class_exists($abstract)) {
135
+			$abstract = __NAMESPACE__."\\$abstract";
136
+		}
137
+
138
+		return $abstract;
139
+	}
140
+
141
+	/**
142
+	 * Throw an exception that the concrete is not instantiable.
143
+	 *
144
+	 * @param string $concrete
145
+	 *
146
+	 * @return void
147
+	 * @throws BindingResolutionException
148
+	 */
149
+	protected function notInstantiable($concrete)
150
+	{
151
+		$message = "Target [$concrete] is not instantiable.";
152
+
153
+		throw new BindingResolutionException($message);
154
+	}
155
+
156
+	/**
157
+	 * Resolve a class based dependency from the container.
158
+	 *
159
+	 * @param mixed $concrete
160
+	 *
161
+	 * @return mixed
162
+	 * @throws BindingResolutionException
163
+	 */
164
+	protected function resolve($concrete)
165
+	{
166
+		if ($concrete instanceof Closure) {
167
+			return $concrete($this);
168
+		}
169
+
170
+		$reflector = new ReflectionClass($concrete);
171
+
172
+		if (!$reflector->isInstantiable()) {
173
+			return $this->notInstantiable($concrete);
174
+		}
175
+
176
+		if (is_null(($constructor = $reflector->getConstructor()))) {
177
+			return new $concrete();
178
+		}
179
+
180
+		return $reflector->newInstanceArgs(
181
+			$this->resolveDependencies($constructor->getParameters())
182
+		);
183
+	}
184
+
185
+	/**
186
+	 * Resolve a class based dependency from the container.
187
+	 *
188
+	 * @return mixed
189
+	 * @throws BindingResolutionException
190
+	 */
191
+	protected function resolveClass(ReflectionParameter $parameter)
192
+	{
193
+		try {
194
+			return $this->make($parameter->getClass()->name);
195
+		} catch (BindingResolutionException $e) {
196
+			if ($parameter->isOptional()) {
197
+				return $parameter->getDefaultValue();
198
+			}
199
+			throw $e;
200
+		}
201
+	}
202
+
203
+	/**
204
+	 * Resolve all of the dependencies from the ReflectionParameters.
205
+	 *
206
+	 * @return array
207
+	 */
208
+	protected function resolveDependencies(array $dependencies)
209
+	{
210
+		$results = [];
211
+
212
+		foreach ($dependencies as $dependency) {
213
+			// If the class is null, the dependency is a string or some other primitive type
214
+			$results[] = !is_null($class = $dependency->getClass())
215
+				? $this->resolveClass($dependency)
216
+				: null;
217
+		}
218
+
219
+		return $results;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public static function getInstance()
39 39
     {
40
-        if (is_null(static::$instance)) {
40
+        if( is_null( static::$instance ) ) {
41 41
             static::$instance = new static();
42 42
         }
43 43
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return mixed
54 54
      */
55
-    public function bind($alias, $concrete)
55
+    public function bind( $alias, $concrete )
56 56
     {
57 57
         $this->services[$alias] = $concrete;
58 58
     }
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return mixed
68 68
      */
69
-    public function make($abstract)
69
+    public function make( $abstract )
70 70
     {
71
-        $service = isset($this->services[$abstract])
71
+        $service = isset( $this->services[$abstract] )
72 72
             ? $this->services[$abstract]
73
-            : $this->addNamespace($abstract);
73
+            : $this->addNamespace( $abstract );
74 74
 
75
-        if (is_callable($service)) {
76
-            return call_user_func_array($service, [$this]);
75
+        if( is_callable( $service ) ) {
76
+            return call_user_func_array( $service, [$this] );
77 77
         }
78
-        if (is_object($service)) {
78
+        if( is_object( $service ) ) {
79 79
             return $service;
80 80
         }
81 81
 
82
-        return $this->resolve($service);
82
+        return $this->resolve( $service );
83 83
     }
84 84
 
85 85
     /**
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return void
92 92
      */
93
-    public function singleton($abstract, $concrete)
93
+    public function singleton( $abstract, $concrete )
94 94
     {
95
-        $this->bind($abstract, $this->make($concrete));
95
+        $this->bind( $abstract, $this->make( $concrete ) );
96 96
     }
97 97
 
98 98
     /**
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @return mixed
104 104
      */
105
-    public function __get($item)
105
+    public function __get( $item )
106 106
     {
107
-        return isset($this->bucket[$item])
107
+        return isset( $this->bucket[$item] )
108 108
             ? $this->bucket[$item]
109 109
             : null;
110 110
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      *
118 118
      * @return void
119 119
      */
120
-    public function __set($item, $value)
120
+    public function __set( $item, $value )
121 121
     {
122 122
         $this->bucket[$item] = $value;
123 123
     }
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return string
131 131
      */
132
-    protected function addNamespace($abstract)
132
+    protected function addNamespace( $abstract )
133 133
     {
134
-        if (false === strpos($abstract, __NAMESPACE__) && !class_exists($abstract)) {
134
+        if( false === strpos( $abstract, __NAMESPACE__ ) && !class_exists( $abstract ) ) {
135 135
             $abstract = __NAMESPACE__."\\$abstract";
136 136
         }
137 137
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
      * @return void
147 147
      * @throws BindingResolutionException
148 148
      */
149
-    protected function notInstantiable($concrete)
149
+    protected function notInstantiable( $concrete )
150 150
     {
151 151
         $message = "Target [$concrete] is not instantiable.";
152 152
 
153
-        throw new BindingResolutionException($message);
153
+        throw new BindingResolutionException( $message );
154 154
     }
155 155
 
156 156
     /**
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
      * @return mixed
162 162
      * @throws BindingResolutionException
163 163
      */
164
-    protected function resolve($concrete)
164
+    protected function resolve( $concrete )
165 165
     {
166
-        if ($concrete instanceof Closure) {
167
-            return $concrete($this);
166
+        if( $concrete instanceof Closure ) {
167
+            return $concrete( $this );
168 168
         }
169 169
 
170
-        $reflector = new ReflectionClass($concrete);
170
+        $reflector = new ReflectionClass( $concrete );
171 171
 
172
-        if (!$reflector->isInstantiable()) {
173
-            return $this->notInstantiable($concrete);
172
+        if( !$reflector->isInstantiable() ) {
173
+            return $this->notInstantiable( $concrete );
174 174
         }
175 175
 
176
-        if (is_null(($constructor = $reflector->getConstructor()))) {
176
+        if( is_null( ( $constructor = $reflector->getConstructor() ) ) ) {
177 177
             return new $concrete();
178 178
         }
179 179
 
180 180
         return $reflector->newInstanceArgs(
181
-            $this->resolveDependencies($constructor->getParameters())
181
+            $this->resolveDependencies( $constructor->getParameters() )
182 182
         );
183 183
     }
184 184
 
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
      * @return mixed
189 189
      * @throws BindingResolutionException
190 190
      */
191
-    protected function resolveClass(ReflectionParameter $parameter)
191
+    protected function resolveClass( ReflectionParameter $parameter )
192 192
     {
193 193
         try {
194
-            return $this->make($parameter->getClass()->name);
195
-        } catch (BindingResolutionException $e) {
196
-            if ($parameter->isOptional()) {
194
+            return $this->make( $parameter->getClass()->name );
195
+        } catch( BindingResolutionException $e ) {
196
+            if( $parameter->isOptional() ) {
197 197
                 return $parameter->getDefaultValue();
198 198
             }
199 199
             throw $e;
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @return array
207 207
      */
208
-    protected function resolveDependencies(array $dependencies)
208
+    protected function resolveDependencies( array $dependencies )
209 209
     {
210 210
         $results = [];
211 211
 
212
-        foreach ($dependencies as $dependency) {
212
+        foreach( $dependencies as $dependency ) {
213 213
             // If the class is null, the dependency is a string or some other primitive type
214
-            $results[] = !is_null($class = $dependency->getClass())
215
-                ? $this->resolveClass($dependency)
214
+            $results[] = !is_null( $class = $dependency->getClass() )
215
+                ? $this->resolveClass( $dependency )
216 216
                 : null;
217 217
         }
218 218
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 use ReflectionClass;
8 8
 use ReflectionParameter;
9 9
 
10
-abstract class Container
11
-{
10
+abstract class Container {
12 11
     /**
13 12
      * The current globally available container (if any).
14 13
      *
@@ -192,7 +191,8 @@  discard block
 block discarded – undo
192 191
     {
193 192
         try {
194 193
             return $this->make($parameter->getClass()->name);
195
-        } catch (BindingResolutionException $e) {
194
+        }
195
+        catch (BindingResolutionException $e) {
196 196
             if ($parameter->isOptional()) {
197 197
                 return $parameter->getDefaultValue();
198 198
             }
Please login to merge, or discard this patch.
src/Gallery.php 3 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -10,294 +10,294 @@
 block discarded – undo
10 10
 
11 11
 class Gallery
12 12
 {
13
-    public $gallery;
14
-
15
-    protected $args;
16
-    protected $image;
17
-    protected $postmeta;
18
-    protected $theme;
19
-    protected $utility;
20
-
21
-    public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility)
22
-    {
23
-        $this->image = $image;
24
-        $this->postmeta = $postmeta;
25
-        $this->theme = $theme;
26
-        $this->utility = $utility;
27
-    }
28
-
29
-    /**
30
-     * @return static
31
-     */
32
-    public function get(array $args = [])
33
-    {
34
-        $this->normalizeArgs($args);
35
-
36
-        $this->gallery = new WP_Query([
37
-            'orderby' => 'post__in',
38
-            'paged' => $this->getPaged(),
39
-            'post__in' => $this->args['media'],
40
-            'post_mime_type' => 'image',
41
-            'post_type' => 'attachment',
42
-            'post_status' => 'inherit',
43
-            'posts_per_page' => $this->args['images_per_page'],
44
-        ]);
45
-        return $this;
46
-    }
47
-
48
-    /**
49
-     * @return string
50
-     */
51
-    public function render()
52
-    {
53
-        if (empty($this->args['media'])) {
54
-            return;
55
-        }
56
-        $images = array_reduce($this->gallery->posts, function ($images, $attachment) {
57
-            return $images.$this->renderImage($attachment);
58
-        });
59
-        return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s',
60
-            $images,
61
-            $this->renderPagination()
62
-        );
63
-    }
64
-
65
-    /**
66
-     * @return string|null
67
-     */
68
-    public function renderImage(WP_Post $attachment)
69
-    {
70
-        $image = $this->image->get($attachment->ID)->image;
71
-
72
-        if (!$image) {
73
-            return;
74
-        }
75
-        return sprintf(
76
-            '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">'.
77
-                '%s%s'.
78
-            '</figure>',
79
-            $image->thumbnail['width'],
80
-            $image->thumbnail['height'],
81
-            $this->getPhotoswipeData($image),
82
-            $this->renderImageTag($image),
83
-            $this->renderImageCaption($image)
84
-        );
85
-    }
86
-
87
-    /**
88
-     * @return string|null
89
-     */
90
-    public function renderPagination()
91
-    {
92
-        if (!$this->args['pagination']) {
93
-            return;
94
-        }
95
-        return paginate_links([
96
-            'before_page_number' => '<span class="screen-reader-text">'.__('Page', 'castor').' </span>',
97
-            'current' => $this->gallery->query['paged'],
98
-            'mid_size' => 1,
99
-            'next_text' => __('Next', 'castor'),
100
-            'prev_text' => __('Previous', 'castor'),
101
-            'total' => $this->gallery->max_num_pages,
102
-        ]);
103
-    }
104
-
105
-    /**
106
-     * @param string $key
107
-     * @param mixed  $value
108
-     *
109
-     * @return bool
110
-     */
111
-    protected function getBoolValue($key, $value = null)
112
-    {
113
-        $bool = $this->getValue($key, $value);
114
-
115
-        if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) {
116
-            $bool = $this->postmeta->get($bool);
117
-        }
118
-        return wp_validate_boolean($bool);
119
-    }
120
-
121
-    /**
122
-     * @param mixed $value
123
-     *
124
-     * @return int
125
-     */
126
-    protected function getGalleryArg($value = null)
127
-    {
128
-        $gallery = $this->getValue('gallery', $value);
129
-
130
-        if (!is_numeric($gallery) && is_string($gallery)) {
131
-            $gallery = intval($this->postmeta->get($gallery));
132
-        }
133
-        return !is_null(get_post($gallery))
134
-            ? intval($gallery)
135
-            : 0;
136
-    }
137
-
138
-    /**
139
-     * @param mixed $value
140
-     *
141
-     * @return int
142
-     */
143
-    protected function getImagesPerPageArg($value = null)
144
-    {
145
-        $perPage = $this->getValue('images_per_page', $value);
146
-
147
-        if (!is_numeric($perPage) && is_string($perPage)) {
148
-            $perPage = $this->postmeta->get($perPage);
149
-        }
150
-        return (bool) intval($perPage)
151
-            ? $perPage
152
-            : -1;
153
-    }
154
-
155
-    /**
156
-     * @param mixed $value
157
-     *
158
-     * @return bool
159
-     */
160
-    protected function getLazyloadArg($value = null)
161
-    {
162
-        return $this->getBoolValue('lazyload', $value);
163
-    }
164
-
165
-    /**
166
-     * @param mixed $value
167
-     *
168
-     * @return array
169
-     */
170
-    protected function getMediaArg($value = null)
171
-    {
172
-        $media = $this->getValue('media', $value);
173
-
174
-        if (is_string($media)) {
175
-            $media = $this->postmeta->get($media, [
176
-                'ID' => $this->getGalleryArg(),
177
-                'single' => false,
178
-            ]);
179
-        }
180
-        return is_array($media)
181
-            ? wp_parse_id_list($media)
182
-            : [];
183
-    }
184
-
185
-    /**
186
-     * @return int
187
-     */
188
-    protected function getPaged()
189
-    {
190
-        return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1;
191
-    }
192
-
193
-    /**
194
-     * @param mixed $value
195
-     *
196
-     * @return bool
197
-     */
198
-    protected function getPaginationArg($value = null)
199
-    {
200
-        return $this->getBoolValue('pagination', $value);
201
-    }
202
-
203
-    /**
204
-     * @param mixed $value
205
-     *
206
-     * @return bool
207
-     */
208
-    protected function getPermalinksArg($value = null)
209
-    {
210
-        return $this->getBoolValue('permalinks', $value);
211
-    }
212
-
213
-    /**
214
-     * @return string
215
-     */
216
-    protected function getPhotoswipeData($image)
217
-    {
218
-        return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
219
-            $image->large['url'],
220
-            $image->large['width'],
221
-            $image->large['height'],
222
-            $image->medium['url'],
223
-            $image->medium['width'],
224
-            $image->medium['height']
225
-        );
226
-    }
227
-
228
-    /**
229
-     * @param string $key
230
-     * @param mixed  $value
231
-     *
232
-     * @return mixed
233
-     */
234
-    protected function getValue($key, $value = null)
235
-    {
236
-        if (is_null($value) && isset($this->args[$key])) {
237
-            $value = $this->args[$key];
238
-        }
239
-        return $value;
240
-    }
241
-
242
-    /**
243
-     * @return array
244
-     */
245
-    protected function normalizeArgs(array $args = [])
246
-    {
247
-        $defaults = [
248
-            'gallery',         // (string) meta_key | (int) post_id
249
-            'lazyload',        // (string) meta_key | (bool)
250
-            'media',           // (string) meta_key | (array) post_ids
251
-            'pagination',      // (string) meta_key | (bool)
252
-            'images_per_page', // (string) meta_key | (int) number
253
-            'permalinks',      // (string) meta_key | (bool)
254
-        ];
255
-
256
-        $this->args = shortcode_atts(array_combine($defaults, $defaults), $args);
257
-
258
-        array_walk($this->args, function (&$value, $key) {
259
-            $method = $this->utility->buildMethodName($key.'_arg');
260
-            if (method_exists($this, $method)) {
261
-                $value = call_user_func([$this, $method], $value);
262
-            }
263
-        });
264
-
265
-        return $this->args;
266
-    }
267
-
268
-    /**
269
-     * @param object $image
270
-     * @return string|null
271
-     */
272
-    protected function renderImageCaption($image)
273
-    {
274
-        if (!empty($image->copyright)) {
275
-            $image->caption .= sprintf(' <span itemprop="copyrightHolder">%s</span>', $image->copyright);
276
-        }
277
-        if (empty($image->caption)) {
278
-            return;
279
-        }
280
-        return sprintf('<figcaption itemprop="caption description">%s</figcaption>', $image->caption);
281
-    }
282
-
283
-    /**
284
-     * @param object $image
285
-     * @return string|null
286
-     */
287
-    protected function renderImageTag($image)
288
-    {
289
-        $imgSrc = $this->getLazyloadArg()
290
-            ? $this->theme->imageUri('blank.gif')
291
-            : $image->thumbnail['url'];
292
-
293
-        $imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
294
-            $imgSrc,
295
-            $image->thumbnail['url'],
296
-            $image->alt
297
-        );
298
-
299
-        return $this->getPermalinksArg()
300
-            ? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag)
301
-            : $imgTag;
302
-    }
13
+	public $gallery;
14
+
15
+	protected $args;
16
+	protected $image;
17
+	protected $postmeta;
18
+	protected $theme;
19
+	protected $utility;
20
+
21
+	public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility)
22
+	{
23
+		$this->image = $image;
24
+		$this->postmeta = $postmeta;
25
+		$this->theme = $theme;
26
+		$this->utility = $utility;
27
+	}
28
+
29
+	/**
30
+	 * @return static
31
+	 */
32
+	public function get(array $args = [])
33
+	{
34
+		$this->normalizeArgs($args);
35
+
36
+		$this->gallery = new WP_Query([
37
+			'orderby' => 'post__in',
38
+			'paged' => $this->getPaged(),
39
+			'post__in' => $this->args['media'],
40
+			'post_mime_type' => 'image',
41
+			'post_type' => 'attachment',
42
+			'post_status' => 'inherit',
43
+			'posts_per_page' => $this->args['images_per_page'],
44
+		]);
45
+		return $this;
46
+	}
47
+
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function render()
52
+	{
53
+		if (empty($this->args['media'])) {
54
+			return;
55
+		}
56
+		$images = array_reduce($this->gallery->posts, function ($images, $attachment) {
57
+			return $images.$this->renderImage($attachment);
58
+		});
59
+		return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s',
60
+			$images,
61
+			$this->renderPagination()
62
+		);
63
+	}
64
+
65
+	/**
66
+	 * @return string|null
67
+	 */
68
+	public function renderImage(WP_Post $attachment)
69
+	{
70
+		$image = $this->image->get($attachment->ID)->image;
71
+
72
+		if (!$image) {
73
+			return;
74
+		}
75
+		return sprintf(
76
+			'<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">'.
77
+				'%s%s'.
78
+			'</figure>',
79
+			$image->thumbnail['width'],
80
+			$image->thumbnail['height'],
81
+			$this->getPhotoswipeData($image),
82
+			$this->renderImageTag($image),
83
+			$this->renderImageCaption($image)
84
+		);
85
+	}
86
+
87
+	/**
88
+	 * @return string|null
89
+	 */
90
+	public function renderPagination()
91
+	{
92
+		if (!$this->args['pagination']) {
93
+			return;
94
+		}
95
+		return paginate_links([
96
+			'before_page_number' => '<span class="screen-reader-text">'.__('Page', 'castor').' </span>',
97
+			'current' => $this->gallery->query['paged'],
98
+			'mid_size' => 1,
99
+			'next_text' => __('Next', 'castor'),
100
+			'prev_text' => __('Previous', 'castor'),
101
+			'total' => $this->gallery->max_num_pages,
102
+		]);
103
+	}
104
+
105
+	/**
106
+	 * @param string $key
107
+	 * @param mixed  $value
108
+	 *
109
+	 * @return bool
110
+	 */
111
+	protected function getBoolValue($key, $value = null)
112
+	{
113
+		$bool = $this->getValue($key, $value);
114
+
115
+		if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) {
116
+			$bool = $this->postmeta->get($bool);
117
+		}
118
+		return wp_validate_boolean($bool);
119
+	}
120
+
121
+	/**
122
+	 * @param mixed $value
123
+	 *
124
+	 * @return int
125
+	 */
126
+	protected function getGalleryArg($value = null)
127
+	{
128
+		$gallery = $this->getValue('gallery', $value);
129
+
130
+		if (!is_numeric($gallery) && is_string($gallery)) {
131
+			$gallery = intval($this->postmeta->get($gallery));
132
+		}
133
+		return !is_null(get_post($gallery))
134
+			? intval($gallery)
135
+			: 0;
136
+	}
137
+
138
+	/**
139
+	 * @param mixed $value
140
+	 *
141
+	 * @return int
142
+	 */
143
+	protected function getImagesPerPageArg($value = null)
144
+	{
145
+		$perPage = $this->getValue('images_per_page', $value);
146
+
147
+		if (!is_numeric($perPage) && is_string($perPage)) {
148
+			$perPage = $this->postmeta->get($perPage);
149
+		}
150
+		return (bool) intval($perPage)
151
+			? $perPage
152
+			: -1;
153
+	}
154
+
155
+	/**
156
+	 * @param mixed $value
157
+	 *
158
+	 * @return bool
159
+	 */
160
+	protected function getLazyloadArg($value = null)
161
+	{
162
+		return $this->getBoolValue('lazyload', $value);
163
+	}
164
+
165
+	/**
166
+	 * @param mixed $value
167
+	 *
168
+	 * @return array
169
+	 */
170
+	protected function getMediaArg($value = null)
171
+	{
172
+		$media = $this->getValue('media', $value);
173
+
174
+		if (is_string($media)) {
175
+			$media = $this->postmeta->get($media, [
176
+				'ID' => $this->getGalleryArg(),
177
+				'single' => false,
178
+			]);
179
+		}
180
+		return is_array($media)
181
+			? wp_parse_id_list($media)
182
+			: [];
183
+	}
184
+
185
+	/**
186
+	 * @return int
187
+	 */
188
+	protected function getPaged()
189
+	{
190
+		return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1;
191
+	}
192
+
193
+	/**
194
+	 * @param mixed $value
195
+	 *
196
+	 * @return bool
197
+	 */
198
+	protected function getPaginationArg($value = null)
199
+	{
200
+		return $this->getBoolValue('pagination', $value);
201
+	}
202
+
203
+	/**
204
+	 * @param mixed $value
205
+	 *
206
+	 * @return bool
207
+	 */
208
+	protected function getPermalinksArg($value = null)
209
+	{
210
+		return $this->getBoolValue('permalinks', $value);
211
+	}
212
+
213
+	/**
214
+	 * @return string
215
+	 */
216
+	protected function getPhotoswipeData($image)
217
+	{
218
+		return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
219
+			$image->large['url'],
220
+			$image->large['width'],
221
+			$image->large['height'],
222
+			$image->medium['url'],
223
+			$image->medium['width'],
224
+			$image->medium['height']
225
+		);
226
+	}
227
+
228
+	/**
229
+	 * @param string $key
230
+	 * @param mixed  $value
231
+	 *
232
+	 * @return mixed
233
+	 */
234
+	protected function getValue($key, $value = null)
235
+	{
236
+		if (is_null($value) && isset($this->args[$key])) {
237
+			$value = $this->args[$key];
238
+		}
239
+		return $value;
240
+	}
241
+
242
+	/**
243
+	 * @return array
244
+	 */
245
+	protected function normalizeArgs(array $args = [])
246
+	{
247
+		$defaults = [
248
+			'gallery',         // (string) meta_key | (int) post_id
249
+			'lazyload',        // (string) meta_key | (bool)
250
+			'media',           // (string) meta_key | (array) post_ids
251
+			'pagination',      // (string) meta_key | (bool)
252
+			'images_per_page', // (string) meta_key | (int) number
253
+			'permalinks',      // (string) meta_key | (bool)
254
+		];
255
+
256
+		$this->args = shortcode_atts(array_combine($defaults, $defaults), $args);
257
+
258
+		array_walk($this->args, function (&$value, $key) {
259
+			$method = $this->utility->buildMethodName($key.'_arg');
260
+			if (method_exists($this, $method)) {
261
+				$value = call_user_func([$this, $method], $value);
262
+			}
263
+		});
264
+
265
+		return $this->args;
266
+	}
267
+
268
+	/**
269
+	 * @param object $image
270
+	 * @return string|null
271
+	 */
272
+	protected function renderImageCaption($image)
273
+	{
274
+		if (!empty($image->copyright)) {
275
+			$image->caption .= sprintf(' <span itemprop="copyrightHolder">%s</span>', $image->copyright);
276
+		}
277
+		if (empty($image->caption)) {
278
+			return;
279
+		}
280
+		return sprintf('<figcaption itemprop="caption description">%s</figcaption>', $image->caption);
281
+	}
282
+
283
+	/**
284
+	 * @param object $image
285
+	 * @return string|null
286
+	 */
287
+	protected function renderImageTag($image)
288
+	{
289
+		$imgSrc = $this->getLazyloadArg()
290
+			? $this->theme->imageUri('blank.gif')
291
+			: $image->thumbnail['url'];
292
+
293
+		$imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
294
+			$imgSrc,
295
+			$image->thumbnail['url'],
296
+			$image->alt
297
+		);
298
+
299
+		return $this->getPermalinksArg()
300
+			? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag)
301
+			: $imgTag;
302
+	}
303 303
 }
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     protected $theme;
19 19
     protected $utility;
20 20
 
21
-    public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility)
21
+    public function __construct( Image $image, PostMeta $postmeta, Theme $theme, Utility $utility )
22 22
     {
23 23
         $this->image = $image;
24 24
         $this->postmeta = $postmeta;
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * @return static
31 31
      */
32
-    public function get(array $args = [])
32
+    public function get( array $args = [] )
33 33
     {
34
-        $this->normalizeArgs($args);
34
+        $this->normalizeArgs( $args );
35 35
 
36
-        $this->gallery = new WP_Query([
36
+        $this->gallery = new WP_Query( [
37 37
             'orderby' => 'post__in',
38 38
             'paged' => $this->getPaged(),
39 39
             'post__in' => $this->args['media'],
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
             'post_type' => 'attachment',
42 42
             'post_status' => 'inherit',
43 43
             'posts_per_page' => $this->args['images_per_page'],
44
-        ]);
44
+        ] );
45 45
         return $this;
46 46
     }
47 47
 
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function render()
52 52
     {
53
-        if (empty($this->args['media'])) {
53
+        if( empty( $this->args['media'] ) ) {
54 54
             return;
55 55
         }
56
-        $images = array_reduce($this->gallery->posts, function ($images, $attachment) {
57
-            return $images.$this->renderImage($attachment);
56
+        $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) {
57
+            return $images.$this->renderImage( $attachment );
58 58
         });
59
-        return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s',
59
+        return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s',
60 60
             $images,
61 61
             $this->renderPagination()
62 62
         );
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @return string|null
67 67
      */
68
-    public function renderImage(WP_Post $attachment)
68
+    public function renderImage( WP_Post $attachment )
69 69
     {
70
-        $image = $this->image->get($attachment->ID)->image;
70
+        $image = $this->image->get( $attachment->ID )->image;
71 71
 
72
-        if (!$image) {
72
+        if( !$image ) {
73 73
             return;
74 74
         }
75 75
         return sprintf(
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
             '</figure>',
79 79
             $image->thumbnail['width'],
80 80
             $image->thumbnail['height'],
81
-            $this->getPhotoswipeData($image),
82
-            $this->renderImageTag($image),
83
-            $this->renderImageCaption($image)
81
+            $this->getPhotoswipeData( $image ),
82
+            $this->renderImageTag( $image ),
83
+            $this->renderImageCaption( $image )
84 84
         );
85 85
     }
86 86
 
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function renderPagination()
91 91
     {
92
-        if (!$this->args['pagination']) {
92
+        if( !$this->args['pagination'] ) {
93 93
             return;
94 94
         }
95
-        return paginate_links([
96
-            'before_page_number' => '<span class="screen-reader-text">'.__('Page', 'castor').' </span>',
95
+        return paginate_links( [
96
+            'before_page_number' => '<span class="screen-reader-text">'.__( 'Page', 'castor' ).' </span>',
97 97
             'current' => $this->gallery->query['paged'],
98 98
             'mid_size' => 1,
99
-            'next_text' => __('Next', 'castor'),
100
-            'prev_text' => __('Previous', 'castor'),
99
+            'next_text' => __( 'Next', 'castor' ),
100
+            'prev_text' => __( 'Previous', 'castor' ),
101 101
             'total' => $this->gallery->max_num_pages,
102
-        ]);
102
+        ] );
103 103
     }
104 104
 
105 105
     /**
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @return bool
110 110
      */
111
-    protected function getBoolValue($key, $value = null)
111
+    protected function getBoolValue( $key, $value = null )
112 112
     {
113
-        $bool = $this->getValue($key, $value);
113
+        $bool = $this->getValue( $key, $value );
114 114
 
115
-        if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) {
116
-            $bool = $this->postmeta->get($bool);
115
+        if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ) ) {
116
+            $bool = $this->postmeta->get( $bool );
117 117
         }
118
-        return wp_validate_boolean($bool);
118
+        return wp_validate_boolean( $bool );
119 119
     }
120 120
 
121 121
     /**
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return int
125 125
      */
126
-    protected function getGalleryArg($value = null)
126
+    protected function getGalleryArg( $value = null )
127 127
     {
128
-        $gallery = $this->getValue('gallery', $value);
128
+        $gallery = $this->getValue( 'gallery', $value );
129 129
 
130
-        if (!is_numeric($gallery) && is_string($gallery)) {
131
-            $gallery = intval($this->postmeta->get($gallery));
130
+        if( !is_numeric( $gallery ) && is_string( $gallery ) ) {
131
+            $gallery = intval( $this->postmeta->get( $gallery ) );
132 132
         }
133
-        return !is_null(get_post($gallery))
134
-            ? intval($gallery)
133
+        return !is_null( get_post( $gallery ) )
134
+            ? intval( $gallery )
135 135
             : 0;
136 136
     }
137 137
 
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @return int
142 142
      */
143
-    protected function getImagesPerPageArg($value = null)
143
+    protected function getImagesPerPageArg( $value = null )
144 144
     {
145
-        $perPage = $this->getValue('images_per_page', $value);
145
+        $perPage = $this->getValue( 'images_per_page', $value );
146 146
 
147
-        if (!is_numeric($perPage) && is_string($perPage)) {
148
-            $perPage = $this->postmeta->get($perPage);
147
+        if( !is_numeric( $perPage ) && is_string( $perPage ) ) {
148
+            $perPage = $this->postmeta->get( $perPage );
149 149
         }
150
-        return (bool) intval($perPage)
150
+        return (bool) intval( $perPage )
151 151
             ? $perPage
152 152
             : -1;
153 153
     }
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return bool
159 159
      */
160
-    protected function getLazyloadArg($value = null)
160
+    protected function getLazyloadArg( $value = null )
161 161
     {
162
-        return $this->getBoolValue('lazyload', $value);
162
+        return $this->getBoolValue( 'lazyload', $value );
163 163
     }
164 164
 
165 165
     /**
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
      *
168 168
      * @return array
169 169
      */
170
-    protected function getMediaArg($value = null)
170
+    protected function getMediaArg( $value = null )
171 171
     {
172
-        $media = $this->getValue('media', $value);
172
+        $media = $this->getValue( 'media', $value );
173 173
 
174
-        if (is_string($media)) {
175
-            $media = $this->postmeta->get($media, [
174
+        if( is_string( $media ) ) {
175
+            $media = $this->postmeta->get( $media, [
176 176
                 'ID' => $this->getGalleryArg(),
177 177
                 'single' => false,
178
-            ]);
178
+            ] );
179 179
         }
180
-        return is_array($media)
181
-            ? wp_parse_id_list($media)
180
+        return is_array( $media )
181
+            ? wp_parse_id_list( $media )
182 182
             : [];
183 183
     }
184 184
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     protected function getPaged()
189 189
     {
190
-        return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1;
190
+        return intval( get_query_var( ( is_front_page() ? 'page' : 'paged' ) ) ) ?: 1;
191 191
     }
192 192
 
193 193
     /**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
      *
196 196
      * @return bool
197 197
      */
198
-    protected function getPaginationArg($value = null)
198
+    protected function getPaginationArg( $value = null )
199 199
     {
200
-        return $this->getBoolValue('pagination', $value);
200
+        return $this->getBoolValue( 'pagination', $value );
201 201
     }
202 202
 
203 203
     /**
@@ -205,17 +205,17 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @return bool
207 207
      */
208
-    protected function getPermalinksArg($value = null)
208
+    protected function getPermalinksArg( $value = null )
209 209
     {
210
-        return $this->getBoolValue('permalinks', $value);
210
+        return $this->getBoolValue( 'permalinks', $value );
211 211
     }
212 212
 
213 213
     /**
214 214
      * @return string
215 215
      */
216
-    protected function getPhotoswipeData($image)
216
+    protected function getPhotoswipeData( $image )
217 217
     {
218
-        return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
218
+        return sprintf( '{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}',
219 219
             $image->large['url'],
220 220
             $image->large['width'],
221 221
             $image->large['height'],
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return mixed
233 233
      */
234
-    protected function getValue($key, $value = null)
234
+    protected function getValue( $key, $value = null )
235 235
     {
236
-        if (is_null($value) && isset($this->args[$key])) {
236
+        if( is_null( $value ) && isset( $this->args[$key] ) ) {
237 237
             $value = $this->args[$key];
238 238
         }
239 239
         return $value;
@@ -242,23 +242,23 @@  discard block
 block discarded – undo
242 242
     /**
243 243
      * @return array
244 244
      */
245
-    protected function normalizeArgs(array $args = [])
245
+    protected function normalizeArgs( array $args = [] )
246 246
     {
247 247
         $defaults = [
248
-            'gallery',         // (string) meta_key | (int) post_id
249
-            'lazyload',        // (string) meta_key | (bool)
250
-            'media',           // (string) meta_key | (array) post_ids
251
-            'pagination',      // (string) meta_key | (bool)
248
+            'gallery', // (string) meta_key | (int) post_id
249
+            'lazyload', // (string) meta_key | (bool)
250
+            'media', // (string) meta_key | (array) post_ids
251
+            'pagination', // (string) meta_key | (bool)
252 252
             'images_per_page', // (string) meta_key | (int) number
253
-            'permalinks',      // (string) meta_key | (bool)
253
+            'permalinks', // (string) meta_key | (bool)
254 254
         ];
255 255
 
256
-        $this->args = shortcode_atts(array_combine($defaults, $defaults), $args);
256
+        $this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args );
257 257
 
258
-        array_walk($this->args, function (&$value, $key) {
259
-            $method = $this->utility->buildMethodName($key.'_arg');
260
-            if (method_exists($this, $method)) {
261
-                $value = call_user_func([$this, $method], $value);
258
+        array_walk( $this->args, function( &$value, $key ) {
259
+            $method = $this->utility->buildMethodName( $key.'_arg' );
260
+            if( method_exists( $this, $method ) ) {
261
+                $value = call_user_func( [$this, $method], $value );
262 262
             }
263 263
         });
264 264
 
@@ -269,35 +269,35 @@  discard block
 block discarded – undo
269 269
      * @param object $image
270 270
      * @return string|null
271 271
      */
272
-    protected function renderImageCaption($image)
272
+    protected function renderImageCaption( $image )
273 273
     {
274
-        if (!empty($image->copyright)) {
275
-            $image->caption .= sprintf(' <span itemprop="copyrightHolder">%s</span>', $image->copyright);
274
+        if( !empty( $image->copyright ) ) {
275
+            $image->caption .= sprintf( ' <span itemprop="copyrightHolder">%s</span>', $image->copyright );
276 276
         }
277
-        if (empty($image->caption)) {
277
+        if( empty( $image->caption ) ) {
278 278
             return;
279 279
         }
280
-        return sprintf('<figcaption itemprop="caption description">%s</figcaption>', $image->caption);
280
+        return sprintf( '<figcaption itemprop="caption description">%s</figcaption>', $image->caption );
281 281
     }
282 282
 
283 283
     /**
284 284
      * @param object $image
285 285
      * @return string|null
286 286
      */
287
-    protected function renderImageTag($image)
287
+    protected function renderImageTag( $image )
288 288
     {
289 289
         $imgSrc = $this->getLazyloadArg()
290
-            ? $this->theme->imageUri('blank.gif')
290
+            ? $this->theme->imageUri( 'blank.gif' )
291 291
             : $image->thumbnail['url'];
292 292
 
293
-        $imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
293
+        $imgTag = sprintf( '<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>',
294 294
             $imgSrc,
295 295
             $image->thumbnail['url'],
296 296
             $image->alt
297 297
         );
298 298
 
299 299
         return $this->getPermalinksArg()
300
-            ? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag)
300
+            ? sprintf( '<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag )
301 301
             : $imgTag;
302 302
     }
303 303
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
 use WP_Post;
9 9
 use WP_Query;
10 10
 
11
-class Gallery
12
-{
11
+class Gallery {
13 12
     public $gallery;
14 13
 
15 14
     protected $args;
Please login to merge, or discard this patch.
src/Application.php 3 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -4,85 +4,85 @@
 block discarded – undo
4 4
 
5 5
 final class Application extends Container
6 6
 {
7
-    public $assets;
8
-    public $cssDir;
9
-    public $imgDir;
10
-    public $jsDir;
7
+	public $assets;
8
+	public $cssDir;
9
+	public $imgDir;
10
+	public $jsDir;
11 11
 
12
-    public function __construct()
13
-    {
14
-        $this->assets = sprintf('%s/assets/', dirname(__DIR__));
15
-        Facade::clearResolvedInstances();
16
-        Facade::setFacadeApplication($this);
17
-        $this->registerAliases();
18
-        $this->registerBindings();
19
-    }
12
+	public function __construct()
13
+	{
14
+		$this->assets = sprintf('%s/assets/', dirname(__DIR__));
15
+		Facade::clearResolvedInstances();
16
+		Facade::setFacadeApplication($this);
17
+		$this->registerAliases();
18
+		$this->registerBindings();
19
+	}
20 20
 
21
-    public function init()
22
-    {
23
-        $controller = $this->make('Controller');
21
+	public function init()
22
+	{
23
+		$controller = $this->make('Controller');
24 24
 
25
-        // Action hooks
26
-        add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20);
27
-        add_action('login_head', [$controller, 'loadAdminFavicon']);
28
-        add_action('admin_head', [$controller, 'loadAdminFavicon']);
29
-        add_action('login_head', [$controller, 'login']);
30
-        add_action('admin_enqueue_scripts', [$controller, 'registerAdminAssets']);
31
-        add_action('wp_enqueue_scripts', [$controller, 'registerAssets']);
32
-        add_action('customize_register', [$controller, 'registerCustomizer']);
33
-        add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']);
34
-        add_action('widgets_init', [$controller, 'registerSidebars']);
25
+		// Action hooks
26
+		add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20);
27
+		add_action('login_head', [$controller, 'loadAdminFavicon']);
28
+		add_action('admin_head', [$controller, 'loadAdminFavicon']);
29
+		add_action('login_head', [$controller, 'login']);
30
+		add_action('admin_enqueue_scripts', [$controller, 'registerAdminAssets']);
31
+		add_action('wp_enqueue_scripts', [$controller, 'registerAssets']);
32
+		add_action('customize_register', [$controller, 'registerCustomizer']);
33
+		add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']);
34
+		add_action('widgets_init', [$controller, 'registerSidebars']);
35 35
 
36
-        // Filter hooks
37
-        add_filter('body_class', [$controller, 'filterBodyClasses']);
38
-        add_filter('template_include', [$controller, 'filterTemplate']);
39
-        add_filter('login_headertext', [$controller, 'filterLoginTitle']);
40
-        add_filter('login_headerurl', [$controller, 'filterLoginUrl']);
36
+		// Filter hooks
37
+		add_filter('body_class', [$controller, 'filterBodyClasses']);
38
+		add_filter('template_include', [$controller, 'filterTemplate']);
39
+		add_filter('login_headertext', [$controller, 'filterLoginTitle']);
40
+		add_filter('login_headerurl', [$controller, 'filterLoginUrl']);
41 41
 
42
-        foreach ($this->getTemplateTypes() as $type) {
43
-            add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']);
44
-        }
45
-    }
42
+		foreach ($this->getTemplateTypes() as $type) {
43
+			add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']);
44
+		}
45
+	}
46 46
 
47
-    /**
48
-     * @return void
49
-     */
50
-    public function registerAliases()
51
-    {
52
-        $aliases = [
53
-            'Development' => Facades\Development::class,
54
-            'Log' => Facades\Log::class,
55
-            'Media' => Facades\Media::class,
56
-            'PostMeta' => Facades\PostMeta::class,
57
-            'Render' => Facades\Render::class,
58
-            'SiteMeta' => Facades\SiteMeta::class,
59
-            'Template' => Facades\Template::class,
60
-            'Theme' => Facades\Theme::class,
61
-            'Utility' => Facades\Utility::class,
62
-        ];
63
-        $aliases = apply_filters('castor/register/aliases', $aliases);
64
-        AliasLoader::getInstance($aliases)->register();
65
-    }
47
+	/**
48
+	 * @return void
49
+	 */
50
+	public function registerAliases()
51
+	{
52
+		$aliases = [
53
+			'Development' => Facades\Development::class,
54
+			'Log' => Facades\Log::class,
55
+			'Media' => Facades\Media::class,
56
+			'PostMeta' => Facades\PostMeta::class,
57
+			'Render' => Facades\Render::class,
58
+			'SiteMeta' => Facades\SiteMeta::class,
59
+			'Template' => Facades\Template::class,
60
+			'Theme' => Facades\Theme::class,
61
+			'Utility' => Facades\Utility::class,
62
+		];
63
+		$aliases = apply_filters('castor/register/aliases', $aliases);
64
+		AliasLoader::getInstance($aliases)->register();
65
+	}
66 66
 
67
-    /**
68
-     * @return void
69
-     */
70
-    public function registerBindings()
71
-    {
72
-        $this->bind(Helpers\Log::class, function () {
73
-            return new Helpers\Log(trailingslashit(get_stylesheet_directory()).'castor-debug.log');
74
-        });
75
-    }
67
+	/**
68
+	 * @return void
69
+	 */
70
+	public function registerBindings()
71
+	{
72
+		$this->bind(Helpers\Log::class, function () {
73
+			return new Helpers\Log(trailingslashit(get_stylesheet_directory()).'castor-debug.log');
74
+		});
75
+	}
76 76
 
77
-    /**
78
-     * @return array
79
-     */
80
-    protected function getTemplateTypes()
81
-    {
82
-        return [
83
-            '404', 'archive', 'attachment', 'author', 'category', 'date',
84
-            'embed', 'frontpage', 'home', 'index', 'page', 'paged',
85
-            'search', 'single', 'singular', 'tag', 'taxonomy',
86
-        ];
87
-    }
77
+	/**
78
+	 * @return array
79
+	 */
80
+	protected function getTemplateTypes()
81
+	{
82
+		return [
83
+			'404', 'archive', 'attachment', 'author', 'category', 'date',
84
+			'embed', 'frontpage', 'home', 'index', 'page', 'paged',
85
+			'search', 'single', 'singular', 'tag', 'taxonomy',
86
+		];
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,36 +11,36 @@  discard block
 block discarded – undo
11 11
 
12 12
     public function __construct()
13 13
     {
14
-        $this->assets = sprintf('%s/assets/', dirname(__DIR__));
14
+        $this->assets = sprintf( '%s/assets/', dirname( __DIR__ ) );
15 15
         Facade::clearResolvedInstances();
16
-        Facade::setFacadeApplication($this);
16
+        Facade::setFacadeApplication( $this );
17 17
         $this->registerAliases();
18 18
         $this->registerBindings();
19 19
     }
20 20
 
21 21
     public function init()
22 22
     {
23
-        $controller = $this->make('Controller');
23
+        $controller = $this->make( 'Controller' );
24 24
 
25 25
         // Action hooks
26
-        add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20);
27
-        add_action('login_head', [$controller, 'loadAdminFavicon']);
28
-        add_action('admin_head', [$controller, 'loadAdminFavicon']);
29
-        add_action('login_head', [$controller, 'login']);
30
-        add_action('admin_enqueue_scripts', [$controller, 'registerAdminAssets']);
31
-        add_action('wp_enqueue_scripts', [$controller, 'registerAssets']);
32
-        add_action('customize_register', [$controller, 'registerCustomizer']);
33
-        add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']);
34
-        add_action('widgets_init', [$controller, 'registerSidebars']);
26
+        add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 );
27
+        add_action( 'login_head', [$controller, 'loadAdminFavicon'] );
28
+        add_action( 'admin_head', [$controller, 'loadAdminFavicon'] );
29
+        add_action( 'login_head', [$controller, 'login'] );
30
+        add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] );
31
+        add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] );
32
+        add_action( 'customize_register', [$controller, 'registerCustomizer'] );
33
+        add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] );
34
+        add_action( 'widgets_init', [$controller, 'registerSidebars'] );
35 35
 
36 36
         // Filter hooks
37
-        add_filter('body_class', [$controller, 'filterBodyClasses']);
38
-        add_filter('template_include', [$controller, 'filterTemplate']);
39
-        add_filter('login_headertext', [$controller, 'filterLoginTitle']);
40
-        add_filter('login_headerurl', [$controller, 'filterLoginUrl']);
37
+        add_filter( 'body_class', [$controller, 'filterBodyClasses'] );
38
+        add_filter( 'template_include', [$controller, 'filterTemplate'] );
39
+        add_filter( 'login_headertext', [$controller, 'filterLoginTitle'] );
40
+        add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] );
41 41
 
42
-        foreach ($this->getTemplateTypes() as $type) {
43
-            add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']);
42
+        foreach( $this->getTemplateTypes() as $type ) {
43
+            add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] );
44 44
         }
45 45
     }
46 46
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
             'Theme' => Facades\Theme::class,
61 61
             'Utility' => Facades\Utility::class,
62 62
         ];
63
-        $aliases = apply_filters('castor/register/aliases', $aliases);
64
-        AliasLoader::getInstance($aliases)->register();
63
+        $aliases = apply_filters( 'castor/register/aliases', $aliases );
64
+        AliasLoader::getInstance( $aliases )->register();
65 65
     }
66 66
 
67 67
     /**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function registerBindings()
71 71
     {
72
-        $this->bind(Helpers\Log::class, function () {
73
-            return new Helpers\Log(trailingslashit(get_stylesheet_directory()).'castor-debug.log');
72
+        $this->bind( Helpers\Log::class, function() {
73
+            return new Helpers\Log( trailingslashit( get_stylesheet_directory() ).'castor-debug.log' );
74 74
         });
75 75
     }
76 76
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace GeminiLabs\Castor;
4 4
 
5
-final class Application extends Container
6
-{
5
+final class Application extends Container {
7 6
     public $assets;
8 7
     public $cssDir;
9 8
     public $imgDir;
Please login to merge, or discard this patch.
src/Oembed.php 3 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -7,89 +7,89 @@
 block discarded – undo
7 7
 
8 8
 class Oembed
9 9
 {
10
-    public $oembed;
11
-    public $utility;
12
-
13
-    public $vimeo = [
14
-        'api', 'autopause', 'autoplay', 'byline', 'color', 'height', 'loop', 'player_id',
15
-        'portrait', 'title', 'width',
16
-    ];
17
-
18
-    public $youtube = [
19
-        'autohide', 'autoplay', 'cc_load_policy', 'color', 'controls', 'disablekb', 'enablejsapi',
20
-        'end', 'fs', 'height', 'hl', 'iv_load_policy', 'list', 'listType', 'loop', 'modestbranding',
21
-        'origin', 'playerapiid', 'playlist', 'playsinline', 'rel', 'showinfo', 'start', 'theme',
22
-        'width',
23
-    ];
24
-
25
-    public function __construct(Utility $utility)
26
-    {
27
-        $this->oembed = _wp_oembed_get_object();
28
-        $this->utility = $utility;
29
-    }
30
-
31
-    public function request($url, $args = '')
32
-    {
33
-        $args = wp_parse_args($args, [
34
-            'embed_type' => '',
35
-        ]);
36
-        $request = $this->oembed->fetch($this->oembed->get_provider($url), $url, [
37
-            'width' => 1280,
38
-            'height' => 1280,
39
-        ]);
40
-        if (false === $request) {
41
-            return;
42
-        }
43
-        if (!empty($args['embed_type']) && $args['embed_type'] != $request->type) {
44
-            return;
45
-        }
46
-        return $this->modifyRequest($request, $args);
47
-    }
48
-
49
-    protected function domLoad($html)
50
-    {
51
-        $dom = new DomDocument();
52
-        $dom->loadHTML($html);
53
-        return $dom;
54
-    }
55
-
56
-    protected function modifyRequest($request, $args)
57
-    {
58
-        $providerName = strtolower($request->provider_name);
59
-        $provider = property_exists($this, $providerName)
60
-            ? $this->$providerName
61
-            : [];
62
-
63
-        $method = $this->utility->buildMethodName($providerName.'_request', 'modify');
64
-
65
-        if (method_exists($this, $method)) {
66
-            return call_user_func([$this, $method], $request, array_intersect_key(
67
-                $args,
68
-                array_flip($provider)
69
-            ));
70
-        }
71
-        return $request;
72
-    }
73
-
74
-    protected function modifyYoutubeRequest($request, array $args)
75
-    {
76
-        $html = $this->domLoad($request->html);
77
-        $node = $html->getElementsByTagName('iframe')->item(0);
78
-        $url = $node->getAttribute('src');
79
-
80
-        if (isset($args['fs']) && 0 == $args['fs']) {
81
-            $node->removeAttribute('allowfullscreen');
82
-        }
83
-
84
-        $args['origin'] = urlencode(get_bloginfo('url'));
85
-
86
-        $node->setAttribute('class', 'video-embed');
87
-        $node->setAttribute('src',
88
-            add_query_arg($args, remove_query_arg('feature', $url))
89
-        );
90
-
91
-        $request->html = $html->saveHTML($node);
92
-
93
-        return $request;
94
-    }
10
+	public $oembed;
11
+	public $utility;
12
+
13
+	public $vimeo = [
14
+		'api', 'autopause', 'autoplay', 'byline', 'color', 'height', 'loop', 'player_id',
15
+		'portrait', 'title', 'width',
16
+	];
17
+
18
+	public $youtube = [
19
+		'autohide', 'autoplay', 'cc_load_policy', 'color', 'controls', 'disablekb', 'enablejsapi',
20
+		'end', 'fs', 'height', 'hl', 'iv_load_policy', 'list', 'listType', 'loop', 'modestbranding',
21
+		'origin', 'playerapiid', 'playlist', 'playsinline', 'rel', 'showinfo', 'start', 'theme',
22
+		'width',
23
+	];
24
+
25
+	public function __construct(Utility $utility)
26
+	{
27
+		$this->oembed = _wp_oembed_get_object();
28
+		$this->utility = $utility;
29
+	}
30
+
31
+	public function request($url, $args = '')
32
+	{
33
+		$args = wp_parse_args($args, [
34
+			'embed_type' => '',
35
+		]);
36
+		$request = $this->oembed->fetch($this->oembed->get_provider($url), $url, [
37
+			'width' => 1280,
38
+			'height' => 1280,
39
+		]);
40
+		if (false === $request) {
41
+			return;
42
+		}
43
+		if (!empty($args['embed_type']) && $args['embed_type'] != $request->type) {
44
+			return;
45
+		}
46
+		return $this->modifyRequest($request, $args);
47
+	}
48
+
49
+	protected function domLoad($html)
50
+	{
51
+		$dom = new DomDocument();
52
+		$dom->loadHTML($html);
53
+		return $dom;
54
+	}
55
+
56
+	protected function modifyRequest($request, $args)
57
+	{
58
+		$providerName = strtolower($request->provider_name);
59
+		$provider = property_exists($this, $providerName)
60
+			? $this->$providerName
61
+			: [];
62
+
63
+		$method = $this->utility->buildMethodName($providerName.'_request', 'modify');
64
+
65
+		if (method_exists($this, $method)) {
66
+			return call_user_func([$this, $method], $request, array_intersect_key(
67
+				$args,
68
+				array_flip($provider)
69
+			));
70
+		}
71
+		return $request;
72
+	}
73
+
74
+	protected function modifyYoutubeRequest($request, array $args)
75
+	{
76
+		$html = $this->domLoad($request->html);
77
+		$node = $html->getElementsByTagName('iframe')->item(0);
78
+		$url = $node->getAttribute('src');
79
+
80
+		if (isset($args['fs']) && 0 == $args['fs']) {
81
+			$node->removeAttribute('allowfullscreen');
82
+		}
83
+
84
+		$args['origin'] = urlencode(get_bloginfo('url'));
85
+
86
+		$node->setAttribute('class', 'video-embed');
87
+		$node->setAttribute('src',
88
+			add_query_arg($args, remove_query_arg('feature', $url))
89
+		);
90
+
91
+		$request->html = $html->saveHTML($node);
92
+
93
+		return $request;
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,73 +22,73 @@
 block discarded – undo
22 22
         'width',
23 23
     ];
24 24
 
25
-    public function __construct(Utility $utility)
25
+    public function __construct( Utility $utility )
26 26
     {
27 27
         $this->oembed = _wp_oembed_get_object();
28 28
         $this->utility = $utility;
29 29
     }
30 30
 
31
-    public function request($url, $args = '')
31
+    public function request( $url, $args = '' )
32 32
     {
33
-        $args = wp_parse_args($args, [
33
+        $args = wp_parse_args( $args, [
34 34
             'embed_type' => '',
35
-        ]);
36
-        $request = $this->oembed->fetch($this->oembed->get_provider($url), $url, [
35
+        ] );
36
+        $request = $this->oembed->fetch( $this->oembed->get_provider( $url ), $url, [
37 37
             'width' => 1280,
38 38
             'height' => 1280,
39
-        ]);
40
-        if (false === $request) {
39
+        ] );
40
+        if( false === $request ) {
41 41
             return;
42 42
         }
43
-        if (!empty($args['embed_type']) && $args['embed_type'] != $request->type) {
43
+        if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type ) {
44 44
             return;
45 45
         }
46
-        return $this->modifyRequest($request, $args);
46
+        return $this->modifyRequest( $request, $args );
47 47
     }
48 48
 
49
-    protected function domLoad($html)
49
+    protected function domLoad( $html )
50 50
     {
51 51
         $dom = new DomDocument();
52
-        $dom->loadHTML($html);
52
+        $dom->loadHTML( $html );
53 53
         return $dom;
54 54
     }
55 55
 
56
-    protected function modifyRequest($request, $args)
56
+    protected function modifyRequest( $request, $args )
57 57
     {
58
-        $providerName = strtolower($request->provider_name);
59
-        $provider = property_exists($this, $providerName)
58
+        $providerName = strtolower( $request->provider_name );
59
+        $provider = property_exists( $this, $providerName )
60 60
             ? $this->$providerName
61 61
             : [];
62 62
 
63
-        $method = $this->utility->buildMethodName($providerName.'_request', 'modify');
63
+        $method = $this->utility->buildMethodName( $providerName.'_request', 'modify' );
64 64
 
65
-        if (method_exists($this, $method)) {
66
-            return call_user_func([$this, $method], $request, array_intersect_key(
65
+        if( method_exists( $this, $method ) ) {
66
+            return call_user_func( [$this, $method], $request, array_intersect_key(
67 67
                 $args,
68
-                array_flip($provider)
69
-            ));
68
+                array_flip( $provider )
69
+            ) );
70 70
         }
71 71
         return $request;
72 72
     }
73 73
 
74
-    protected function modifyYoutubeRequest($request, array $args)
74
+    protected function modifyYoutubeRequest( $request, array $args )
75 75
     {
76
-        $html = $this->domLoad($request->html);
77
-        $node = $html->getElementsByTagName('iframe')->item(0);
78
-        $url = $node->getAttribute('src');
76
+        $html = $this->domLoad( $request->html );
77
+        $node = $html->getElementsByTagName( 'iframe' )->item( 0 );
78
+        $url = $node->getAttribute( 'src' );
79 79
 
80
-        if (isset($args['fs']) && 0 == $args['fs']) {
81
-            $node->removeAttribute('allowfullscreen');
80
+        if( isset( $args['fs'] ) && 0 == $args['fs'] ) {
81
+            $node->removeAttribute( 'allowfullscreen' );
82 82
         }
83 83
 
84
-        $args['origin'] = urlencode(get_bloginfo('url'));
84
+        $args['origin'] = urlencode( get_bloginfo( 'url' ) );
85 85
 
86
-        $node->setAttribute('class', 'video-embed');
87
-        $node->setAttribute('src',
88
-            add_query_arg($args, remove_query_arg('feature', $url))
86
+        $node->setAttribute( 'class', 'video-embed' );
87
+        $node->setAttribute( 'src',
88
+            add_query_arg( $args, remove_query_arg( 'feature', $url ) )
89 89
         );
90 90
 
91
-        $request->html = $html->saveHTML($node);
91
+        $request->html = $html->saveHTML( $node );
92 92
 
93 93
         return $request;
94 94
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use GeminiLabs\Castor\Helpers\Utility;
6 6
 use DomDocument;
7 7
 
8
-class Oembed
9
-{
8
+class Oembed {
10 9
     public $oembed;
11 10
     public $utility;
12 11
 
Please login to merge, or discard this patch.
src/Video.php 3 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -8,117 +8,117 @@
 block discarded – undo
8 8
 
9 9
 class Video
10 10
 {
11
-    public $video;
11
+	public $video;
12 12
 
13
-    protected $args;
14
-    protected $image;
15
-    protected $oembed;
16
-    protected $postmeta;
17
-    protected $supported = ['youtube'];
18
-    protected $theme;
19
-    protected $utility;
13
+	protected $args;
14
+	protected $image;
15
+	protected $oembed;
16
+	protected $postmeta;
17
+	protected $supported = ['youtube'];
18
+	protected $theme;
19
+	protected $utility;
20 20
 
21
-    public function __construct(Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility)
22
-    {
23
-        $this->image = $image;
24
-        $this->oembed = $oembed;
25
-        $this->postmeta = $postmeta;
26
-        $this->theme = $theme;
27
-        $this->utility = $utility;
28
-    }
21
+	public function __construct(Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility)
22
+	{
23
+		$this->image = $image;
24
+		$this->oembed = $oembed;
25
+		$this->postmeta = $postmeta;
26
+		$this->theme = $theme;
27
+		$this->utility = $utility;
28
+	}
29 29
 
30
-    public function get($args = [])
31
-    {
32
-        $args = $this->normalize($args);
33
-        $embed = $this->oembed->request($args['url'], $args['player']);
34
-        if (isset($embed->type) && 'video' == $embed->type) {
35
-            $this->video = $embed;
36
-        }
37
-        return $this;
38
-    }
30
+	public function get($args = [])
31
+	{
32
+		$args = $this->normalize($args);
33
+		$embed = $this->oembed->request($args['url'], $args['player']);
34
+		if (isset($embed->type) && 'video' == $embed->type) {
35
+			$this->video = $embed;
36
+		}
37
+		return $this;
38
+	}
39 39
 
40
-    public function render()
41
-    {
42
-        if (!isset($this->video->html)) {
43
-            return;
44
-        }
45
-        return sprintf(
46
-            '<div class="video embed">%s%s</div>',
47
-            $this->renderScreenshot(),
48
-            $this->video->html
49
-        );
50
-    }
40
+	public function render()
41
+	{
42
+		if (!isset($this->video->html)) {
43
+			return;
44
+		}
45
+		return sprintf(
46
+			'<div class="video embed">%s%s</div>',
47
+			$this->renderScreenshot(),
48
+			$this->video->html
49
+		);
50
+	}
51 51
 
52
-    public function renderPlayButton()
53
-    {
54
-        return sprintf(
55
-            '<div class="video-play">'.
56
-                '<div class="video-play-pulse pulse1"></div>'.
57
-                '<div class="video-play-pulse pulse2"></div>'.
58
-                '<div class="video-play-pulse pulse3"></div>'.
59
-                '<a href="%s" class="video-play-btn">%s</a>'.
60
-            '</div>',
61
-            $this->args['url'],
62
-            $this->theme->svg('play.svg')
63
-        );
64
-    }
52
+	public function renderPlayButton()
53
+	{
54
+		return sprintf(
55
+			'<div class="video-play">'.
56
+				'<div class="video-play-pulse pulse1"></div>'.
57
+				'<div class="video-play-pulse pulse2"></div>'.
58
+				'<div class="video-play-pulse pulse3"></div>'.
59
+				'<a href="%s" class="video-play-btn">%s</a>'.
60
+			'</div>',
61
+			$this->args['url'],
62
+			$this->theme->svg('play.svg')
63
+		);
64
+	}
65 65
 
66
-    public function renderScreenshot()
67
-    {
68
-        if ($this->args['image']
69
-            && in_array(strtolower($this->video->provider_name), $this->supported)) {
70
-            return sprintf('%s<div class="video-poster" style="background-image: url(%s)">%s</div>',
71
-                $this->renderSpinner(),
72
-                $this->args['image'],
73
-                $this->renderPlayButton()
74
-            );
75
-        }
76
-    }
66
+	public function renderScreenshot()
67
+	{
68
+		if ($this->args['image']
69
+			&& in_array(strtolower($this->video->provider_name), $this->supported)) {
70
+			return sprintf('%s<div class="video-poster" style="background-image: url(%s)">%s</div>',
71
+				$this->renderSpinner(),
72
+				$this->args['image'],
73
+				$this->renderPlayButton()
74
+			);
75
+		}
76
+	}
77 77
 
78
-    public function renderSpinner()
79
-    {
80
-        return sprintf(
81
-            '<div class="video-spinner">'.
82
-                '<div class="spinner"><div class="spinner-dots">%s</div></div>'.
83
-            '</div>',
84
-            implode('', array_fill(0, 8, '<div class="spinner-dot"></div>'))
85
-        );
86
-    }
78
+	public function renderSpinner()
79
+	{
80
+		return sprintf(
81
+			'<div class="video-spinner">'.
82
+				'<div class="spinner"><div class="spinner-dots">%s</div></div>'.
83
+			'</div>',
84
+			implode('', array_fill(0, 8, '<div class="spinner-dot"></div>'))
85
+		);
86
+	}
87 87
 
88
-    protected function setImage($image)
89
-    {
90
-        $image = $this->image->get($image)->image;
91
-        $this->args['image'] = isset($image->large)
92
-            ? $image->large['url']
93
-            : null;
94
-    }
88
+	protected function setImage($image)
89
+	{
90
+		$image = $this->image->get($image)->image;
91
+		$this->args['image'] = isset($image->large)
92
+			? $image->large['url']
93
+			: null;
94
+	}
95 95
 
96
-    protected function setUrl($url)
97
-    {
98
-        $this->args['url'] = !filter_var($url, FILTER_VALIDATE_URL)
99
-            ? $this->postmeta->get($url)
100
-            : $url;
101
-    }
96
+	protected function setUrl($url)
97
+	{
98
+		$this->args['url'] = !filter_var($url, FILTER_VALIDATE_URL)
99
+			? $this->postmeta->get($url)
100
+			: $url;
101
+	}
102 102
 
103
-    protected function normalize($args)
104
-    {
105
-        if (is_string($args)) {
106
-            $args = ['url' => $args];
107
-        }
103
+	protected function normalize($args)
104
+	{
105
+		if (is_string($args)) {
106
+			$args = ['url' => $args];
107
+		}
108 108
 
109
-        $this->args = shortcode_atts([
110
-            'image' => '', // string || int
111
-            'player' => '', // string || array
112
-            'url' => '', // string
113
-        ], $args);
109
+		$this->args = shortcode_atts([
110
+			'image' => '', // string || int
111
+			'player' => '', // string || array
112
+			'url' => '', // string
113
+		], $args);
114 114
 
115
-        foreach ($this->args as $key => $value) {
116
-            $method = $this->utility->buildMethodName($key, 'set');
117
-            if (!method_exists($this, $method)) {
118
-                continue;
119
-            }
120
-            call_user_func([$this, $method], $value);
121
-        }
122
-        return $this->args;
123
-    }
115
+		foreach ($this->args as $key => $value) {
116
+			$method = $this->utility->buildMethodName($key, 'set');
117
+			if (!method_exists($this, $method)) {
118
+				continue;
119
+			}
120
+			call_user_func([$this, $method], $value);
121
+		}
122
+		return $this->args;
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     protected $theme;
19 19
     protected $utility;
20 20
 
21
-    public function __construct(Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility)
21
+    public function __construct( Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility )
22 22
     {
23 23
         $this->image = $image;
24 24
         $this->oembed = $oembed;
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
         $this->utility = $utility;
28 28
     }
29 29
 
30
-    public function get($args = [])
30
+    public function get( $args = [] )
31 31
     {
32
-        $args = $this->normalize($args);
33
-        $embed = $this->oembed->request($args['url'], $args['player']);
34
-        if (isset($embed->type) && 'video' == $embed->type) {
32
+        $args = $this->normalize( $args );
33
+        $embed = $this->oembed->request( $args['url'], $args['player'] );
34
+        if( isset( $embed->type ) && 'video' == $embed->type ) {
35 35
             $this->video = $embed;
36 36
         }
37 37
         return $this;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function render()
41 41
     {
42
-        if (!isset($this->video->html)) {
42
+        if( !isset( $this->video->html ) ) {
43 43
             return;
44 44
         }
45 45
         return sprintf(
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
                 '<a href="%s" class="video-play-btn">%s</a>'.
60 60
             '</div>',
61 61
             $this->args['url'],
62
-            $this->theme->svg('play.svg')
62
+            $this->theme->svg( 'play.svg' )
63 63
         );
64 64
     }
65 65
 
66 66
     public function renderScreenshot()
67 67
     {
68
-        if ($this->args['image']
69
-            && in_array(strtolower($this->video->provider_name), $this->supported)) {
70
-            return sprintf('%s<div class="video-poster" style="background-image: url(%s)">%s</div>',
68
+        if( $this->args['image']
69
+            && in_array( strtolower( $this->video->provider_name ), $this->supported ) ) {
70
+            return sprintf( '%s<div class="video-poster" style="background-image: url(%s)">%s</div>',
71 71
                 $this->renderSpinner(),
72 72
                 $this->args['image'],
73 73
                 $this->renderPlayButton()
@@ -81,43 +81,43 @@  discard block
 block discarded – undo
81 81
             '<div class="video-spinner">'.
82 82
                 '<div class="spinner"><div class="spinner-dots">%s</div></div>'.
83 83
             '</div>',
84
-            implode('', array_fill(0, 8, '<div class="spinner-dot"></div>'))
84
+            implode( '', array_fill( 0, 8, '<div class="spinner-dot"></div>' ) )
85 85
         );
86 86
     }
87 87
 
88
-    protected function setImage($image)
88
+    protected function setImage( $image )
89 89
     {
90
-        $image = $this->image->get($image)->image;
91
-        $this->args['image'] = isset($image->large)
90
+        $image = $this->image->get( $image )->image;
91
+        $this->args['image'] = isset( $image->large )
92 92
             ? $image->large['url']
93 93
             : null;
94 94
     }
95 95
 
96
-    protected function setUrl($url)
96
+    protected function setUrl( $url )
97 97
     {
98
-        $this->args['url'] = !filter_var($url, FILTER_VALIDATE_URL)
99
-            ? $this->postmeta->get($url)
98
+        $this->args['url'] = !filter_var( $url, FILTER_VALIDATE_URL )
99
+            ? $this->postmeta->get( $url )
100 100
             : $url;
101 101
     }
102 102
 
103
-    protected function normalize($args)
103
+    protected function normalize( $args )
104 104
     {
105
-        if (is_string($args)) {
105
+        if( is_string( $args ) ) {
106 106
             $args = ['url' => $args];
107 107
         }
108 108
 
109
-        $this->args = shortcode_atts([
109
+        $this->args = shortcode_atts( [
110 110
             'image' => '', // string || int
111 111
             'player' => '', // string || array
112 112
             'url' => '', // string
113
-        ], $args);
113
+        ], $args );
114 114
 
115
-        foreach ($this->args as $key => $value) {
116
-            $method = $this->utility->buildMethodName($key, 'set');
117
-            if (!method_exists($this, $method)) {
115
+        foreach( $this->args as $key => $value ) {
116
+            $method = $this->utility->buildMethodName( $key, 'set' );
117
+            if( !method_exists( $this, $method ) ) {
118 118
                 continue;
119 119
             }
120
-            call_user_func([$this, $method], $value);
120
+            call_user_func( [$this, $method], $value );
121 121
         }
122 122
         return $this->args;
123 123
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@
 block discarded – undo
6 6
 use GeminiLabs\Castor\Helpers\Theme;
7 7
 use GeminiLabs\Castor\Helpers\Utility;
8 8
 
9
-class Video
10
-{
9
+class Video {
11 10
     public $video;
12 11
 
13 12
     protected $args;
Please login to merge, or discard this patch.