Passed
Push — master ( 51995c...0bccda )
by Paul
06:07 queued 02:50
created

Component   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
init() 0 1 ?
register() 0 1 ?
A normalizeThis() 0 11 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
	/**
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