Completed
Push — develop ( 079584...9aa6f3 )
by Paul
02:09
created
src/Oembed.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -22,65 +22,65 @@
 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
-		$request = $this->oembed->fetch( $this->oembed->get_provider( $url ), $url, [
33
+		$request = $this->oembed->fetch($this->oembed->get_provider($url), $url, [
34 34
 			'width'  => 1280,
35 35
 			'height' => 1280,
36 36
 		]);
37
-		if( $request ) {
38
-			return $this->modifyRequest( $request, $args );
37
+		if ($request) {
38
+			return $this->modifyRequest($request, $args);
39 39
 		}
40 40
 	}
41 41
 
42
-	protected function domLoad( $html )
42
+	protected function domLoad($html)
43 43
 	{
44 44
 		$dom = new DomDocument;
45
-		$dom->loadHTML( $html );
45
+		$dom->loadHTML($html);
46 46
 		return $dom;
47 47
 	}
48 48
 
49
-	protected function modifyRequest( $request, $args )
49
+	protected function modifyRequest($request, $args)
50 50
 	{
51
-		$providerName = strtolower( $request->provider_name );
52
-		$provider = property_exists( $this, $providerName )
51
+		$providerName = strtolower($request->provider_name);
52
+		$provider = property_exists($this, $providerName)
53 53
 			? $this->$providerName
54 54
 			: [];
55 55
 
56
-		$method = $this->utility->buildMethodName( $providerName . '_request', 'modify' );
56
+		$method = $this->utility->buildMethodName($providerName . '_request', 'modify');
57 57
 
58
-		if( method_exists( $this, $method )) {
59
-			return call_user_func( [$this, $method], $request, array_intersect_key(
60
-				wp_parse_args( $args ),
61
-				array_flip( $provider )
58
+		if (method_exists($this, $method)) {
59
+			return call_user_func([$this, $method], $request, array_intersect_key(
60
+				wp_parse_args($args),
61
+				array_flip($provider)
62 62
 			));
63 63
 		}
64 64
 		return $request;
65 65
 	}
66 66
 
67
-	protected function modifyYoutubeRequest( $request, array $args )
67
+	protected function modifyYoutubeRequest($request, array $args)
68 68
 	{
69
-		$html = $this->domLoad( $request->html );
70
-		$node = $html->getElementsByTagName( 'iframe' )->item(0);
71
-		$url  = $node->getAttribute( 'src' );
69
+		$html = $this->domLoad($request->html);
70
+		$node = $html->getElementsByTagName('iframe')->item(0);
71
+		$url  = $node->getAttribute('src');
72 72
 
73
-		if( isset( $args['fs'] ) && $args['fs'] == 0 ) {
74
-			$node->removeAttribute( 'allowfullscreen' );
73
+		if (isset($args['fs']) && $args['fs'] == 0) {
74
+			$node->removeAttribute('allowfullscreen');
75 75
 		}
76 76
 
77
-		$args['origin'] = urlencode( get_bloginfo( 'url' ));
77
+		$args['origin'] = urlencode(get_bloginfo('url'));
78 78
 
79
-		$node->setAttribute( 'src',
80
-			add_query_arg( $args, remove_query_arg( 'feature', $url ))
79
+		$node->setAttribute('src',
80
+			add_query_arg($args, remove_query_arg('feature', $url))
81 81
 		);
82 82
 
83
-		$request->html = $html->saveHTML( $node );
83
+		$request->html = $html->saveHTML($node);
84 84
 
85 85
 		return $request;
86 86
 	}
Please login to merge, or discard this patch.
src/Image.php 2 patches
Spacing   +21 added lines, -21 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
-		if( !( $attachment = $this->normalize( $attachment )))return;
29
-		if( $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
+		if (!($attachment = $this->normalize($attachment)))return;
29
+		if ($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->post_type != 'attachment' )return;
62
+		if (is_null($attachment) || $attachment->post_type != 'attachment')return;
63 63
 
64 64
 		return $attachment->ID;
65 65
 	}
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return array
71 71
 	 */
72
-	protected function normalizeSrc( array $image, $fallback = false )
72
+	protected function normalizeSrc(array $image, $fallback = false)
73 73
 	{
74
-		if( is_array( $fallback ) && count( array_diff( $image, $fallback )) < 2 ) {
74
+		if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) {
75 75
 			$image = $fallback;
76 76
 		}
77 77
 		return [
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function get( $attachment )
27 27
 	{
28
-		if( !( $attachment = $this->normalize( $attachment )))return;
28
+		if( !( $attachment = $this->normalize( $attachment ))) {
29
+			return;
30
+		}
29 31
 		if( $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' )) {
30 32
 			$medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail );
31 33
 			$large = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'large' ), $medium );
@@ -59,7 +61,9 @@  discard block
 block discarded – undo
59 61
 
60 62
 		$attachment = get_post( $attachmentId );
61 63
 
62
-		if( is_null( $attachment ) || $attachment->post_type != 'attachment' )return;
64
+		if( is_null( $attachment ) || $attachment->post_type != 'attachment' ) {
65
+			return;
66
+		}
63 67
 
64 68
 		return $attachment->ID;
65 69
 	}
Please login to merge, or discard this patch.
src/Helpers/Media.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	protected $image;
22 22
 	protected $video;
23 23
 
24
-	public function __construct( Gallery $gallery, Image $image, Video $video )
24
+	public function __construct(Gallery $gallery, Image $image, Video $video)
25 25
 	{
26 26
 		$this->gallery = $gallery;
27 27
 		$this->image   = $image;
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 	 * @return string|void
35 35
 	 * @throws BadMethodCallException
36 36
 	 */
37
-	public function __call( $name, array $args )
37
+	public function __call($name, array $args)
38 38
 	{
39
-		$mediaType = $this->validateMethod( $name );
39
+		$mediaType = $this->validateMethod($name);
40 40
 
41
-		if( !count( $args )) {
42
-			throw new BadMethodCallException( sprintf( 'Missing arguments for: %s', $name ));
41
+		if (!count($args)) {
42
+			throw new BadMethodCallException(sprintf('Missing arguments for: %s', $name));
43 43
 		}
44
-		if( str_replace( $mediaType, '', strtolower( $name ))) {
45
-			return $this->$mediaType->get( $args[0] )->$mediaType;
44
+		if (str_replace($mediaType, '', strtolower($name))) {
45
+			return $this->$mediaType->get($args[0])->$mediaType;
46 46
 		}
47
-		return !empty( $args[1] )
48
-			? $this->$mediaType->get( $args[0] )->render( $args[1] )
49
-			: $this->$mediaType->get( $args[0] )->render();
47
+		return !empty($args[1])
48
+			? $this->$mediaType->get($args[0])->render($args[1])
49
+			: $this->$mediaType->get($args[0])->render();
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 * @return mixed
57 57
 	 * @throws BadMethodCallException
58 58
 	 */
59
-	public function get( $name, $args = [] )
59
+	public function get($name, $args = [])
60 60
 	{
61
-		$mediaType = $this->validateMethod( $name );
62
-		return $this->$mediaType->get( $args )->$mediaType;
61
+		$mediaType = $this->validateMethod($name);
62
+		return $this->$mediaType->get($args)->$mediaType;
63 63
 	}
64 64
 
65 65
 	/**
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 	 * @return string|false
69 69
 	 * @throws BadMethodCallException
70 70
 	 */
71
-	protected function validateMethod( $name )
71
+	protected function validateMethod($name)
72 72
 	{
73
-		foreach( [$name, strtolower( substr( $name, 3 ))] as $method ) {
74
-			if( property_exists( $this, $method ) && is_object( $this->$method )) {
73
+		foreach ([$name, strtolower(substr($name, 3))] as $method) {
74
+			if (property_exists($this, $method) && is_object($this->$method)) {
75 75
 				return $method;
76 76
 			}
77 77
 		}
78
-		throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ));
78
+		throw new BadMethodCallException(sprintf('Not a valid method: %s', $name));
79 79
 	}
80 80
 }
Please login to merge, or discard this patch.
src/Helpers/PostMeta.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,24 +4,24 @@  discard block
 block discarded – undo
4 4
 
5 5
 class PostMeta
6 6
 {
7
-	public function get( $value, array $args = [] )
7
+	public function get($value, array $args = [])
8 8
 	{
9
-		if( empty( $value ))return;
9
+		if (empty($value))return;
10 10
 
11
-		$args = $this->normalize( $args );
11
+		$args = $this->normalize($args);
12 12
 
13
-		if( substr( $value, 0, 1 ) == '_' && !empty( $args['prefix'] )) {
14
-			$args['prefix'] = sprintf( '_%s', rtrim( $args['prefix'], '_' ));
13
+		if (substr($value, 0, 1) == '_' && !empty($args['prefix'])) {
14
+			$args['prefix'] = sprintf('_%s', rtrim($args['prefix'], '_'));
15 15
 		}
16 16
 
17
-		$metaValue = get_post_meta( $args['ID'], $args['prefix'] . $value, $args['single'] );
17
+		$metaValue = get_post_meta($args['ID'], $args['prefix'] . $value, $args['single']);
18 18
 
19
-		return empty( $metaValue )
19
+		return empty($metaValue)
20 20
 			? $args['fallback']
21 21
 			: $metaValue;
22 22
 	}
23 23
 
24
-	protected function normalize( array $args )
24
+	protected function normalize(array $args)
25 25
 	{
26 26
 		$defaults = [
27 27
 			'ID'       => get_the_ID(),
@@ -29,6 +29,6 @@  discard block
 block discarded – undo
29 29
 			'single'   => true,
30 30
 			'prefix'   => 'pollux_',
31 31
 		];
32
-		return shortcode_atts( $defaults, $args );
32
+		return shortcode_atts($defaults, $args);
33 33
 	}
34 34
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@
 block discarded – undo
6 6
 {
7 7
 	public function get( $value, array $args = [] )
8 8
 	{
9
-		if( empty( $value ))return;
9
+		if( empty( $value )) {
10
+			return;
11
+		}
10 12
 
11 13
 		$args = $this->normalize( $args );
12 14
 
Please login to merge, or discard this patch.