GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 88f370...1732e9 )
by Brad
06:19
created

alter_image_attributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Adds support for WPRocket in FooGallery
4
 * Created by brad.
5
 * Date: 11/06/2017
6
 *
7
 * @since 1.3.3
8
 */
9
if ( ! class_exists( 'FooGallery_WPRocket_Compatibility' ) ) {
10
11
	class FooGallery_WPRocket_Compatibility {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
13
		function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
			add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'alter_image_attributes' ), 999, 3 );
15
			add_filter( 'foogallery_attachment_html_link_attributes', array( $this, 'alter_link_attributes' ), 999, 3 );
16
		}
17
18
		/**
19
		 * Alters the image URL's to use WP Rocket's get_rocket_cdn_url function
20
		 *
21
		 * @uses "foogallery_attachment_html_image_attributes" filter
22
		 *
23
		 * @param                             $attr
24
		 * @param                             $args
25
		 * @param object|FooGalleryAttachment $object
26
		 *
27
		 * @return array
28
		 */
29
		function alter_image_attributes( $attr, $args, $object ) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
31
			if ( isset( $attr[ 'src' ] ) ) {
32
				$attr[ 'src' ] = $this->replace_url( $attr[ 'src' ] );
33
			}
34
35
			return $attr;
36
		}
37
38
		/**
39
		 * Alters the image URL's to use WP Rocket's get_rocket_cdn_url function
40
		 *
41
		 * @uses "foogallery_attachment_html_link_attributes" filter
42
		 *
43
		 * @param                             $attr
44
		 * @param                             $args
45
		 * @param object|FooGalleryAttachment $object
46
		 *
47
		 * @return array
48
		 */
49
		function alter_link_attributes( $attr, $args, $object ) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
50
51
			if ( isset( $attr[ 'href' ] ) ) {
52
				$attr[ 'href' ] = $this->replace_url( $attr[ 'href' ] );
53
			}
54
55
			return $attr;
56
		}
57
58
		function replace_url( $url ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
59
			if ( function_exists( 'get_rocket_cdn_url' ) ) {
60
				return get_rocket_cdn_url( $url );
61
			}
62
63
			return $url;
64
		}
65
	}
66
}
67