NarWidgets   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 89
Duplicated Lines 10.11 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 9
loc 89
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A nar_iframe_id() 0 7 2
A nar_iframe_class() 9 9 2
A get_mvp_program_widget() 0 4 1
A get_home_ownership_matters_widget() 0 6 1
A get_code_of_ethics_widget() 0 3 1
A get_nar_conf_expo_widget() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/* Exit if accessed directly. */
4
if ( ! defined( 'ABSPATH' ) ) { exit; }
5
6
if ( ! class_exists( 'NarWidgets' ) ) {
7
8
	/**
9
	 * NarWidgets class.
10
	 */
11
	class NarWidgets {
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
		/**
14
		 * __construct function.
15
		 *
16
		 * @access public
17
		 * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
18
		 */
19
		public function __construct() {
20
		}
21
22
23
		/**
24
		 * Nar Iframe ID Names.
25
		 *
26
		 * @access public
27
		 * @param string $iframe_id (default: '')
28
		 * @return void
29
		 */
30
		public function nar_iframe_id( $iframe_id = '' ) {
31
32
			if ( '' !== $iframe_id  ) {
33
				return sanitize_html_class( $iframe_id ) . '-iframe';
34
			}
35
36
		}
37
38
		/**
39
		 * Nar Iframe Class Names.
40
		 *
41
		 * @access public
42
		 * @param string $widget_name (default: '')
43
		 * @return void
44
		 */
45 View Code Duplication
		public function nar_iframe_class( $widget_name = '' ) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
47
			if ( '' !== $widget_name ) {
48
				return 'nar nar-iframe nar-' . sanitize_html_class( $widget_name ) . '-iframe';
49
			} else {
50
				return 'nar nar-iframe';
51
			}
52
53
		}
54
55
		/**
56
		 * get_mvp_program_widget function.
57
		 *
58
		 * @access public
59
		 * @return void
60
		 */
61
		public function get_mvp_program_widget() {
62
63
			echo '<iframe frameborder="0" id="'. nar_iframe_id() .'" class="'. $this->zillow_iframe_class( 'mvp-program' ) .'" title="'. __('NAR MVP Program.', 're-pro') .'" src="https://static.realtor.org/ro/widget/mvpwidget.html" scrolling="no" width="300"  height="250"></iframe>';
0 ignored issues
show
Bug introduced by
The method zillow_iframe_class() does not seem to exist on object<NarWidgets>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
		}
65
66
		/**
67
		 * get_home_ownership_matters_widget function.
68
		 *
69
		 * @access public
70
		 * @return void
71
		 */
72
		public function get_home_ownership_matters_widget() {
73
74
			// wp_enqueue_script( 'nar-message', 'http://www.realtor.org/sites/all/themes/rotheme/js/narmessage.js', 'jquery', null, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
75
76
			echo '<iframe id="'. nar_iframe_id() .' class="'. $this->zillow_iframe_class( 'home-ownership-matters' ) .'"  title="'. __('NAR Home Hownership Matters.', 're-pro') .'"  src="https://www.realtor.org/sites/all/themes/rotheme/html/narmessage.html" frameborder="0" width="180" height="250" scrolling="no"></iframe></noscript>';
0 ignored issues
show
Bug introduced by
The method zillow_iframe_class() does not seem to exist on object<NarWidgets>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
		}
78
79
		/**
80
		 * get_code_of_ethics_widget function.
81
		 *
82
		 * @access public
83
		 * @return void
84
		 */
85
		public function get_code_of_ethics_widget() {
86
			echo '<iframe id="'. nar_iframe_id() .' class="'. $this->zillow_iframe_class( 'code-of-ethics' ) .'" title="'. __('NAR Code of Ethics.', 're-pro') .'" frameborder="0" width="300" height="250" src="https://www.realtor.org/node/7504/embed" scrolling="no"></iframe>';
0 ignored issues
show
Bug introduced by
The method zillow_iframe_class() does not seem to exist on object<NarWidgets>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87
		}
88
89
		/**
90
		 * get_nar_conf_expo_widget function.
91
		 *
92
		 * @access public
93
		 * @return void
94
		 */
95
		public function get_nar_conf_expo_widget() {
96
			echo '<iframe id="'. nar_iframe_id() .' class="'. $this->zillow_iframe_class( 'conference-expo' ) .'" title="'. __('NAR Conferences and Expos.', 're-pro') .'" frameborder="0" width="300" height="250" src="https://www.realtor.org/node/10695/embed" scrolling="no"></iframe>';
0 ignored issues
show
Bug introduced by
The method zillow_iframe_class() does not seem to exist on object<NarWidgets>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
		}
98
99
	}
100
101
}
102