Passed
Push — master ( d80a24...27be6d )
by Nirjhar
02:00
created

CGSS_SCAN::design_display()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) exit;
3
4
/**
5
 * Perform scan action
6
 */
7
if ( ! class_exists( 'CGSS_SCAN' ) ) {
8
9
	final class CGSS_SCAN {
10
11
12
		public function __construct() {
13
14
			$post_id = intval($_GET['scan']);
15
			$url = get_permalink( $post_id );
0 ignored issues
show
Bug introduced by
The function get_permalink 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

15
			$url = /** @scrutinizer ignore-call */ get_permalink( $post_id );
Loading history...
16
17
			if (class_exists('CGSS_CRAWL')) {
18
19
				$crawl = new CGSS_CRAWL();
0 ignored issues
show
Bug introduced by
The type CGSS_CRAWL 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...
20
				$crawl->url = esc_url_raw($url);
0 ignored issues
show
Bug introduced by
The function esc_url_raw 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

20
				$crawl->url = /** @scrutinizer ignore-call */ esc_url_raw($url);
Loading history...
21
				$crawl->do();
22
				$result = $crawl->result();
23
24
				update_post_meta( $post_id, 'cgss_scan_result', $result );
0 ignored issues
show
Bug introduced by
The function update_post_meta 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

24
				/** @scrutinizer ignore-call */ 
25
    update_post_meta( $post_id, 'cgss_scan_result', $result );
Loading history...
25
26
				$this->render($result);
27
			}
28
		}
29
30
31
		//Display the score
32
		public function score_html() {
33
34
			$score_html = '';
35
36
			return $score_html;
37
		}
38
39
40
		// Display the snippets
41
		public function snippet_display() {
42
43
			$snippet_html = '';
44
45
			return $snippet_html;
46
		}
47
48
49
		// Display text and link data
50
		public function text_display() {
51
52
			$text_html = '';
53
54
			return $text_html;
55
		}
56
57
58
		// Display design data
59
		public function design_display() {
60
61
62
			$design_html = '';
63
64
			return $design_html;
65
		}
66
67
68
		// Display crawl data
69
		public function crawl_display() {
70
71
			$crawl_html = '';
72
73
			return $crawl_html;
74
		}
75
76
77
		// Display speed data
78
		public function speed_display() {
79
80
			$speed_html = '';
81
82
			return $speed_html;
83
		}
84
85
86
		// Render the HTML
87
		public function render($result) {
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed. ( Ignorable by Annotation )

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

87
		public function render(/** @scrutinizer ignore-unused */ $result) {

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

Loading history...
88
89
			$this->score	= $this->score_html();
0 ignored issues
show
Bug Best Practice introduced by
The property score does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
90
			$this->snippets	= $this->snippet_display();
0 ignored issues
show
Bug Best Practice introduced by
The property snippets does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
91
			$this->text = $this->text_display();
0 ignored issues
show
Bug Best Practice introduced by
The property text does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
92
			$this->design = $this->design_display();
0 ignored issues
show
Bug Best Practice introduced by
The property design does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
93
			$this->crawl = $this->crawl_display();
0 ignored issues
show
Bug Best Practice introduced by
The property crawl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
94
			$this->speed = $this->speed_display();
0 ignored issues
show
Bug Best Practice introduced by
The property speed does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
95
96
			$this->box( null, null, $this->score );
97
			$this->box( __( 'Snippets', 'cgss' ), $this->dashicon('align-none'), $this->snippets );
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

97
			$this->box( /** @scrutinizer ignore-call */ __( 'Snippets', 'cgss' ), $this->dashicon('align-none'), $this->snippets );
Loading history...
98
			$this->box( __( 'Text & Links', 'cgss' ), $this->dashicon('text'), $this->text );
99
			$this->box( __( 'Design', 'cgss' ), $this->dashicon('smartphone'), $this->design );
100
			$this->box( __( 'Crawl', 'cgss' ), $this->dashicon('randomize'), $this->crawl );
101
			$this->box( __( 'Speed', 'cgss' ), $this->dashicon('clock'), $this->speed );
102
		}
103
104
105
		public function box($title, $icon, $desc) {
106
107
			echo 
108
			'<div class="postbox">
109
				<div class="inside">
110
					<div class="main">' .
111
						'<h3>' . $icon . ' ' . $title . '</h3>' .
112
						$desc .
113
					'</div>
114
				</div>
115
			</div>';
116
		}
117
118
119
		public function dashicon($icon) {
120
121
			return '<span class="dashicons dashicons-'.$icon.'"></span>';
122
		}
123
	}
124
} ?>
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...