Component::normalizeThis()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 3
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 12
rs 10
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