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.

FooGallery_Extension   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A convertToObject() 0 10 4
A load() 0 24 1
1
<?php
2
/**
3
 * FooGallery Extension Class that holds all information about an extension
4
 *
5
 * Date: 19/03/2017
6
 */
7
if ( ! class_exists( 'FooGallery_Extension' ) ) {
8
9
	class FooGallery_Extension extends stdClass {
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
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...
10
11
		/**
12
		 * private constructor
13
		 *
14
		 * @param array $array
15
		 */
16
		private function __construct( $array = null ) {
17
			if ( $array !== null ) {
18
				$this->load( $array );
19
			}
20
		}
21
22
		private function convertToObject( $array, $parent = null ) {
23
			$object = ( null === $parent ) ? $this : new stdClass();
24
			foreach ( $array as $key => $value ) {
25
				if ( is_array( $value ) ) {
26
					$value = convertToObject( $value, $object );
27
				}
28
				$object->$key = $value;
29
			}
30
			return $object;
31
		}
32
33
		function load( $array ) {
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...
34
			$this->convertToObject( $array );
35
//			'slug' => 'foobox',
0 ignored issues
show
Unused Code Comprehensibility introduced by
49% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
//				'class' => 'FooGallery_FooBox_Extension',
37
//				'categories' => array( 'Featured', 'Premium' ),
38
//				'file' => 'foobox.php',
39
//				'title' => 'FooBox PRO',
40
//				'description' => 'The best lightbox for WordPress just got even better!',
41
//				'price' => '$27',
42
//				'author' => 'FooPlugins',
43
//				'author_url' => 'http://fooplugins.com',
44
//				'thumbnail' => '/assets/extension_bg.png',
45
//				'tags' => array( 'premium', 'lightbox', ),
46
//				'source' => 'fooplugins',
47
//				'download_button' =>
48
//					array(
49
//						'text' => 'Buy - $27',
50
//						'target' => '_blank',
51
//						'href' => 'http://fooplugins.com/plugins/foobox',
52
//						'confirm' => false,
53
//					),
54
//				'activated_by_default' => true,
55
//				'minimum_version' => '2.3.2',
56
		}
57
	}
58
}