Loader   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 49
dl 0
loc 132
rs 10
c 1
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A db_uninstall() 0 6 1
A settings() 0 3 1
A installation() 0 12 1
A instance() 0 8 2
A insight() 0 3 1
A insert_prelim_data() 0 20 3
A scripts() 0 3 1
A init() 0 13 1
A db_install() 0 11 1
A scan() 0 3 1
1
<?php
2
namespace NirjharLo\Cgss;
3
4
if ( ! defined( 'ABSPATH' ) ) exit;
5
6
7
use \NirjharLo\Cgss\Lib\Script;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Lib\Script was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
use \NirjharLo\Cgss\Lib\Action\Scan;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Lib\Action\Scan was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use \NirjharLo\Cgss\Lib\Action\Insight;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Lib\Action\Insight was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
use \NirjharLo\Cgss\Models\Insight as InsightModel;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Models\Insight was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
use \NirjharLo\Cgss\Src\Db;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Src\Db was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use \NirjharLo\Cgss\Src\Install;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Src\Install was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use \NirjharLo\Cgss\Src\Settings;
0 ignored issues
show
Bug introduced by
The type \NirjharLo\Cgss\Src\Settings was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
18
19
final class Loader {
20
21
	/**
22
	 * Plugin Instance.
23
	 *
24
	 * @var PLUGIN_BUILD the PLUGIN Instance
0 ignored issues
show
Bug introduced by
The type NirjharLo\Cgss\PLUGIN_BUILD was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
	 */
26
	protected static $instance;
27
28
29
	/**
30
	 * Main Plugin Instance.
31
	 *
32
	 * @return PLUGIN_BUILD
33
	 */
34
	public static function instance() {
35
36
		if ( is_null( self::$instance ) ) {
37
			self::$instance = new self();
0 ignored issues
show
Documentation Bug introduced by
It seems like new self() of type NirjharLo\Cgss\Loader is incompatible with the declared type NirjharLo\Cgss\PLUGIN_BUILD of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
			self::$instance->init();
39
		}
40
41
		return self::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::instance also could return the type NirjharLo\Cgss\Loader which is incompatible with the documented return type NirjharLo\Cgss\PLUGIN_BUILD.
Loading history...
42
	}
43
44
	public function installation() {
45
46
			$install = new Install();
47
			$install->textDomin = 'cgss';
48
			$install->phpVerAllowed = '5.4';
49
			$install->pluginPageLinks = array(
50
											array(
51
												'slug' => home_url().'/wp-admin/admin.php?page=seo-scan',
0 ignored issues
show
Bug introduced by
The function home_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
												'slug' => /** @scrutinizer ignore-call */ home_url().'/wp-admin/admin.php?page=seo-scan',
Loading history...
52
												'label' => __( 'Dashboard', 'cgss' )
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
												'label' => /** @scrutinizer ignore-call */ __( 'Dashboard', 'cgss' )
Loading history...
53
											),
54
										);
55
			$install->execute();
56
	}
57
58
59
	public function db_install() {
60
61
			$db = new Db();
62
			$db->table = 'cgss_insight';
63
			$db->sql = "ID mediumint(9) NOT NULL AUTO_INCREMENT,
64
						item varchar(256) NOT NULL,
65
						remark varchar(512) NOT NULL,
66
						UNIQUE KEY ID (ID)";
67
			$db->build();
68
69
			$insert_data = $this->insert_prelim_data();
0 ignored issues
show
Unused Code introduced by
The assignment to $insert_data is dead and can be removed.
Loading history...
Bug introduced by
Are you sure the assignment to $insert_data is correct as $this->insert_prelim_data() targeting NirjharLo\Cgss\Loader::insert_prelim_data() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
70
	}
71
72
73
	public function db_uninstall() {
74
75
		$tableName = 'cgss_insight';
76
77
		global $wpdb;
78
		$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$tableName" );
79
	}
80
81
82
        public function insert_prelim_data() {
83
84
                $model = new InsightModel();
85
86
                if ($model->count() === 0) {
87
88
                $init_insight = array(
89
                                __('Score','cgss'),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
                                /** @scrutinizer ignore-call */ 
90
                                __('Score','cgss'),
Loading history...
90
                                __('Snippet','cgss'),
91
                                __('Text','cgss'),
92
                                __('Links','cgss'),
93
                                __('Keywords','cgss'),
94
                                __('Images','cgss'),
95
                                __('Responsive','cgss'),
96
                                __('Speed','cgss'),
97
                                __('Social','cgss')
98
                        );
99
                $no_data = __( 'No scan reports are available yet', 'cgss' );
100
                foreach ($init_insight as $key => $value) {
101
                        $model->insert($value, $no_data, $key + 1);
102
                }
103
                }
104
        }
105
106
107
	//Include scripts
108
	public function scripts() {
109
110
		new Script();
111
	}
112
113
114
115
	//Include settings pages
116
	public function settings() {
117
118
		new Settings();
119
	}
120
121
122
123
	// Add custom insight action
124
	public function insight() {
125
126
		new Insight();
127
	}
128
129
130
131
	// Add custom insight action
132
	public function scan() {
133
134
		new Scan();
135
	}
136
137
138
	public function init() {
139
140
		register_activation_hook( CGSS_FILE, array( $this, 'db_install' ) );
0 ignored issues
show
Bug introduced by
The function register_activation_hook was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

140
		/** @scrutinizer ignore-call */ 
141
  register_activation_hook( CGSS_FILE, array( $this, 'db_install' ) );
Loading history...
141
		register_uninstall_hook( CGSS_FILE, array( 'BUILD', 'db_uninstall' ) ); //$this won't work here.
0 ignored issues
show
Bug introduced by
The function register_uninstall_hook was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
		/** @scrutinizer ignore-call */ 
142
  register_uninstall_hook( CGSS_FILE, array( 'BUILD', 'db_uninstall' ) ); //$this won't work here.
Loading history...
142
143
		add_action('init', array($this, 'installation'));
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

143
		/** @scrutinizer ignore-call */ 
144
  add_action('init', array($this, 'installation'));
Loading history...
144
145
		$this->scripts();
146
		$this->settings();
147
148
		// Add custom actions, defined in settings
149
		add_action( 'cgss_scan', array( $this, 'scan' ) );
150
		add_action( 'cgss_fetch_insight', array( $this, 'insight' ) );
151
	}
152
} ?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
153