@@ -8,9 +8,9 @@ |
||
8 | 8 | class Component_textarea |
9 | 9 | extends AbstractComponent |
10 | 10 | implements ValueComponentInterface, |
11 | - DisableableComponentInterface, |
|
12 | - FilterableComponentInterface, |
|
13 | - ValidatableComponentInterface |
|
11 | + DisableableComponentInterface, |
|
12 | + FilterableComponentInterface, |
|
13 | + ValidatableComponentInterface |
|
14 | 14 | { |
15 | 15 | public $component_type = 'textarea'; |
16 | 16 |
@@ -8,9 +8,9 @@ |
||
8 | 8 | class Component_text |
9 | 9 | extends AbstractComponent |
10 | 10 | implements ValueComponentInterface, |
11 | - DisableableComponentInterface, |
|
12 | - FilterableComponentInterface, |
|
13 | - ValidatableComponentInterface |
|
11 | + DisableableComponentInterface, |
|
12 | + FilterableComponentInterface, |
|
13 | + ValidatableComponentInterface |
|
14 | 14 | { |
15 | 15 | public $component_type = 'text'; |
16 | 16 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | class Component_radio |
9 | 9 | extends AbstractComponent |
10 | 10 | implements ValueComponentInterface, |
11 | - DisableableComponentInterface |
|
11 | + DisableableComponentInterface |
|
12 | 12 | { |
13 | 13 | public $component_type = 'radio'; |
14 | 14 |
@@ -50,6 +50,9 @@ discard block |
||
50 | 50 | else throw new \RuntimeException("A component of type '$type' has already been registered."); |
51 | 51 | } |
52 | 52 | |
53 | + /** |
|
54 | + * @param string $path |
|
55 | + */ |
|
53 | 56 | public static function get_url( $path ) |
54 | 57 | { |
55 | 58 | $url = str_replace( ABSPATH, '', $path ); |
@@ -58,8 +61,8 @@ discard block |
||
58 | 61 | |
59 | 62 | /** |
60 | 63 | * |
61 | - * @param type $type |
|
62 | - * @param type $props |
|
64 | + * @param string $type |
|
65 | + * @param type string |
|
63 | 66 | * @throws \RuntimeException |
64 | 67 | */ |
65 | 68 | private static function create_core_component( $type, $props ) |
@@ -85,8 +88,8 @@ discard block |
||
85 | 88 | |
86 | 89 | /** |
87 | 90 | * |
88 | - * @param type $type |
|
89 | - * @param type $props |
|
91 | + * @param string $type |
|
92 | + * @param type string |
|
90 | 93 | * @throws \RuntimeException |
91 | 94 | */ |
92 | 95 | private static function create_registered_component( $type, $props ) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param array $props |
21 | 21 | * @return AbstractComponent |
22 | 22 | */ |
23 | - public static function create( $type, array $props ) |
|
23 | + public static function create($type, array $props) |
|
24 | 24 | { |
25 | 25 | try { |
26 | 26 | $component = self::create_registered_component($type, $props); |
@@ -41,19 +41,19 @@ discard block |
||
41 | 41 | * @param string $class_name |
42 | 42 | * @throws \RuntimeException |
43 | 43 | */ |
44 | - public static function register( $type, $class_name ) |
|
44 | + public static function register($type, $class_name) |
|
45 | 45 | { |
46 | - if( !in_array($type, self::$registered_components) ) |
|
46 | + if (!in_array($type, self::$registered_components)) |
|
47 | 47 | { |
48 | 48 | self::$registered_components[$type] = $class_name; |
49 | 49 | } |
50 | 50 | else throw new \RuntimeException("A component of type '$type' has already been registered."); |
51 | 51 | } |
52 | 52 | |
53 | - public static function get_url( $path ) |
|
53 | + public static function get_url($path) |
|
54 | 54 | { |
55 | - $url = str_replace( ABSPATH, '', $path ); |
|
56 | - return esc_url_raw( site_url( $url ) ); |
|
55 | + $url = str_replace(ABSPATH, '', $path); |
|
56 | + return esc_url_raw(site_url($url)); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param type $props |
63 | 63 | * @throws \RuntimeException |
64 | 64 | */ |
65 | - private static function create_core_component( $type, $props ) |
|
65 | + private static function create_core_component($type, $props) |
|
66 | 66 | { |
67 | 67 | $file_name = __DIR__."/components/$type/controller.php"; |
68 | 68 | $class_name = 'Amarkal\\UI\\Component_'.$type; |
69 | 69 | |
70 | 70 | // Load one of the core components |
71 | - if(!class_exists($class_name)) |
|
71 | + if (!class_exists($class_name)) |
|
72 | 72 | { |
73 | - if( file_exists( $file_name ) ) |
|
73 | + if (file_exists($file_name)) |
|
74 | 74 | { |
75 | 75 | require_once $file_name; |
76 | 76 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @param type $props |
90 | 90 | * @throws \RuntimeException |
91 | 91 | */ |
92 | - private static function create_registered_component( $type, $props ) |
|
92 | + private static function create_registered_component($type, $props) |
|
93 | 93 | { |
94 | - if(in_array($type, self::$registered_components)) |
|
94 | + if (in_array($type, self::$registered_components)) |
|
95 | 95 | { |
96 | 96 | $class_name = self::$registered_components[$type]; |
97 | 97 | return new $class_name($props); |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | if( !in_array($type, self::$registered_components) ) |
47 | 47 | { |
48 | 48 | self::$registered_components[$type] = $class_name; |
49 | + } else { |
|
50 | + throw new \RuntimeException("A component of type '$type' has already been registered."); |
|
49 | 51 | } |
50 | - else throw new \RuntimeException("A component of type '$type' has already been registered."); |
|
51 | 52 | } |
52 | 53 | |
53 | 54 | public static function get_url( $path ) |
@@ -73,8 +74,7 @@ discard block |
||
73 | 74 | if( file_exists( $file_name ) ) |
74 | 75 | { |
75 | 76 | require_once $file_name; |
76 | - } |
|
77 | - else |
|
77 | + } else |
|
78 | 78 | { |
79 | 79 | throw new \RuntimeException("A component of type '$type' does not exist."); |
80 | 80 | } |