Passed
Push — develop ( e6e477...3b1736 )
by Paul
03:05
created

Component::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
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
	/**
11
	 * @var Application
12
	 */
13
	protected $app;
14
15
	public function __construct( Application $app )
16
	{
17
		$this->app = $app;
18
	}
19
20
	/**
21
	 * @return void
22
	 */
23
	abstract public function init();
24
25
	/**
26
	 * @return void|array
27
	 */
28
	abstract public function register();
29
30
	/**
31
	 * @param string $id
32
	 * @return array
33
	 */
34
	protected function normalizeThis( $data, array $defaults, $id )
35
	{
36
		$data = wp_parse_args( $data, $defaults );
37
		foreach( $defaults as $key => $value ) {
38
			$method = ( new Helper )->buildMethodName( $key, 'normalize' );
39
			if( method_exists( $this, $method )) {
40
				$data[$key] = $this->$method( $data[$key], $data, $id );
41
			}
42
		}
43
		return $data;
44
	}
45
}
46