Shortcode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace NirjharLo\WP_Plugin_Framework\Src;
3
4
if ( ! defined( 'ABSPATH' ) ) exit;
5
6
/**
7
 * Shortcode class for rendering in front end
8
 *
9
 * @author     Nirjhar Lo
10
 * @package    wp-plugin-framework
11
 */
12
if ( ! class_exists( 'Shortcode' ) ) {
13
14
	class Shortcode {
15
16
		/**
17
		 * Add Shortcode
18
		 *
19
		 * @return Void
20
		 */
21
		public function __construct() {
22
23
			add_shortcode( 'shortcode_name', array( $this, 'cb' ) );
0 ignored issues
show
Bug introduced by
The function add_shortcode 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

23
			/** @scrutinizer ignore-call */ 
24
   add_shortcode( 'shortcode_name', array( $this, 'cb' ) );
Loading history...
24
		}
25
26
	   /**
27
	    * Shortcode callback
28
		*
29
		* @param Array $atts
30
		*
31
		* @return Html
0 ignored issues
show
Bug introduced by
The type NirjharLo\WP_Plugin_Framework\Src\Html 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...
32
		*/
33
		public function cb($atts) {
34
35
			$data = shortcode_atts( array(
0 ignored issues
show
Bug introduced by
The function shortcode_atts 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

35
			$data = /** @scrutinizer ignore-call */ shortcode_atts( array(
Loading history...
Unused Code introduced by
The assignment to $data is dead and can be removed.
Loading history...
36
										'type' => 'zip',
37
									), $atts );
38
39
			return $this->html();
40
		}
41
42
43
		/**
44
		 * Shortcode Display
45
		 *
46
		 * @return Html
47
		 */
48
		public function html() { ?>
49
50
			<div class="class">
51
				Some text.
52
			</div>
53
		<?php
54
		}
55
	}
56
} ?>
57