Plugin   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 90
rs 10
wmc 7
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get_definitions() 0 3 1
A set_definitions() 0 6 1
A register_hooks() 0 10 2
A register_view() 0 6 1
A register_type() 0 6 1
A load_textdomain() 0 3 1
1
<?php
2
namespace testContent;
3
4
/**
5
 * Class to load hooks and set/get base plugin definitions.
6
 *
7
 * @package    WordPress
8
 * @subpackage Evans
9
 * @author     Old Town Media
10
 */
11
class Plugin{
12
13
	/**
14
	 * Plugin definitions.
15
	 *
16
	 * @var object
17
	 */
18
	protected $definitions;
19
20
21
	/**
22
	 * Retrieve the plugin definitions from the main plugin directory.
23
	 *
24
	 * @return object Defitions
25
	 */
26
	public function get_definitions() {
27
		return $this->definitions;
28
	}
29
30
31
	/**
32
	 * Set the plugin definitions.
33
	 *
34
	 * @param  object $definitions Information about the plugin
35
	 * @return object $this
36
	 */
37
	public function set_definitions( $definitions ) {
38
39
		$this->definitions = $definitions;
40
		return $this;
41
42
	}
43
44
45
	/**
46
	 * Register hook function.
47
	 *
48
	 * @param  object $provider Hook provider.
49
	 * @return object $this
50
	 */
51
	public function register_hooks( $provider ) {
52
53
		if ( method_exists( $provider, 'set_plugin' ) ) {
54
			$provider->set_plugin( $this );
55
		}
56
57
		$provider->hooks();
58
		return $this;
59
60
	}
61
62
63
	/**
64
	 * Register hook function.
65
	 *
66
	 * @param  object $provider Hook provider.
67
	 * @return object $this
68
	 */
69
	public function register_view( $provider ) {
70
71
		$provider->register_view();
72
		return $this;
73
74
	}
75
76
77
	/**
78
	 * Register hook function.
79
	 *
80
	 * @param  object $provider Hook provider.
81
	 * @return object $this
82
	 */
83
	public function register_type( $provider ) {
84
85
		$provider->register_type();
86
		return $this;
87
88
	}
89
90
91
	/**
92
	 * Load the textdomain for this plugin if translation is available
93
	 *
94
	 * @see load_plugin_textdomain
95
	 */
96
	public function load_textdomain() {
97
	    load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
98
	}
99
100
}
101