Component   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 39
ccs 0
cts 10
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A normalizeThis() 0 10 3
1
<?php
2
3
namespace GeminiLabs\Pollux;
4
5
use GeminiLabs\Pollux\Application;
6
use GeminiLabs\Pollux\Helper;
7
8
abstract class Component
9
{
10
	const DEPENDENCY = '';
11
	const CAPABILITY = '';
12
13
	/**
14
	 * @var Application
15
	 */
16
	protected $app;
17
18
	public function __construct( Application $app )
19
	{
20
		$this->app = $app;
21
	}
22
23
	/**
24
	 * @return void
25
	 */
26
	abstract public function init();
27
28
	/**
29
	 * @return void|array
30
	 */
31
	abstract public function register();
32
33
	/**
34
	 * @param string $id
35
	 * @return array
36
	 */
37
	protected function normalizeThis( $data, array $defaults, $id )
38
	{
39
		$data = wp_parse_args( $data, $defaults );
40
		foreach( $defaults as $key => $value ) {
41
			$method = Helper::buildMethodName( $key, 'normalize' );
42
			if( method_exists( $this, $method )) {
43
				$data[$key] = $this->$method( $data[$key], $data, $id );
44
			}
45
		}
46
		return $data;
47
	}
48
}
49