@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @param array $model |
17 | 17 | */ |
18 | - public function __construct( array $model = array() ) |
|
18 | + public function __construct(array $model = array()) |
|
19 | 19 | { |
20 | - $this->set_model( $model ); |
|
20 | + $this->set_model($model); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return mixed the argument's value. |
29 | 29 | */ |
30 | - public function __get( $name ) |
|
30 | + public function __get($name) |
|
31 | 31 | { |
32 | - if( isset( $this->model[$name] ) ) |
|
32 | + if (isset($this->model[$name])) |
|
33 | 33 | { |
34 | 34 | return $this->model[$name]; |
35 | 35 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return mixed the settings' argument value. |
45 | 45 | */ |
46 | - public function __set( $name, $value ) |
|
46 | + public function __set($name, $value) |
|
47 | 47 | { |
48 | 48 | $this->model[$name] = $value; |
49 | 49 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function set_model( $model ) |
|
66 | + public function set_model($model) |
|
67 | 67 | { |
68 | 68 | $this->model = $model; |
69 | 69 | } |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | * @return string The rendered template. |
82 | 82 | * @throws TemplateNotFoundException Thrown if the template file cannot be found. |
83 | 83 | */ |
84 | - public function render( $echo = false ){ |
|
84 | + public function render($echo = false) { |
|
85 | 85 | |
86 | 86 | $rendered_html = ''; |
87 | 87 | |
88 | - if( file_exists( $this->get_template_path() ) ) |
|
88 | + if (file_exists($this->get_template_path())) |
|
89 | 89 | { |
90 | 90 | ob_start(); |
91 | - include( $this->get_template_path() ); |
|
91 | + include($this->get_template_path()); |
|
92 | 92 | $rendered_html = ob_get_clean(); |
93 | 93 | } |
94 | 94 | else |
95 | 95 | { |
96 | - throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_template_path() ); |
|
96 | + throw new \RuntimeException("Error: cannot render HTML, template file not found at ".$this->get_template_path()); |
|
97 | 97 | } |
98 | 98 | |
99 | - if( !$echo ) |
|
99 | + if (!$echo) |
|
100 | 100 | { |
101 | 101 | return $rendered_html; |
102 | 102 | } |
@@ -90,8 +90,7 @@ |
||
90 | 90 | ob_start(); |
91 | 91 | include( $this->get_template_path() ); |
92 | 92 | $rendered_html = ob_get_clean(); |
93 | - } |
|
94 | - else |
|
93 | + } else |
|
95 | 94 | { |
96 | 95 | throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_template_path() ); |
97 | 96 | } |
@@ -10,25 +10,25 @@ discard block |
||
10 | 10 | * @link https://github.com/askupasoftware/amarkal-ui |
11 | 11 | * @copyright 2017 Askupa Software |
12 | 12 | */ |
13 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
13 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Prevent loading the library more than once |
17 | 17 | */ |
18 | -if( defined( 'AMARKAL_UI' ) ) return; |
|
19 | -define( 'AMARKAL_UI', true ); |
|
18 | +if (defined('AMARKAL_UI')) return; |
|
19 | +define('AMARKAL_UI', true); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Load required classes if not using composer |
23 | 23 | */ |
24 | -if( !class_exists('Composer\\Autoload\\ClassLoader') ) |
|
24 | +if (!class_exists('Composer\\Autoload\\ClassLoader')) |
|
25 | 25 | { |
26 | 26 | require_once 'renderer.php'; |
27 | 27 | require_once 'abstract-controller.php'; |
28 | 28 | require_once 'abstract-component.php'; |
29 | 29 | } |
30 | 30 | |
31 | -if(!function_exists('amarkal_ui_render')) |
|
31 | +if (!function_exists('amarkal_ui_render')) |
|
32 | 32 | { |
33 | 33 | /** |
34 | 34 | * Render a UI component. |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @param array $props The component's properties |
39 | 39 | * @return string The rendered HTML |
40 | 40 | */ |
41 | - function amarkal_ui_render( $type, array $props = array() ) |
|
41 | + function amarkal_ui_render($type, array $props = array()) |
|
42 | 42 | { |
43 | 43 | $renderer = Amarkal\UI\Renderer::get_instance(); |
44 | - return $renderer->render_component( $type, $props ); |
|
44 | + return $renderer->render_component($type, $props); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | -if(!function_exists('amarkal_ui_register_component')) |
|
48 | +if (!function_exists('amarkal_ui_register_component')) |
|
49 | 49 | { |
50 | 50 | /** |
51 | 51 | * Register a custom UI component. The registered component's class should |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * to one of the core component's type, it will override the core component. |
56 | 56 | * @param string $class_name The component's class name. |
57 | 57 | */ |
58 | - function amarkal_ui_register_component( $type, $class_name ) |
|
58 | + function amarkal_ui_register_component($type, $class_name) |
|
59 | 59 | { |
60 | 60 | $renderer = Amarkal\UI\Renderer::get_instance(); |
61 | - $renderer->register_component( $type, $class_name ); |
|
61 | + $renderer->register_component($type, $class_name); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function required_arguments() |
23 | 23 | { |
24 | - return array('name','data'); |
|
24 | + return array('name', 'data'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function get_template_path() |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @param array $model |
15 | 15 | */ |
16 | - public function __construct( array $model = array() ) |
|
16 | + public function __construct(array $model = array()) |
|
17 | 17 | { |
18 | 18 | parent::__construct($model); |
19 | 19 | $this->on_created(); |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - public function set_model( $model ) |
|
51 | + public function set_model($model) |
|
52 | 52 | { |
53 | 53 | // Check that the required arguments are provided. |
54 | - foreach( $this->required_arguments() as $key ) |
|
54 | + foreach ($this->required_arguments() as $key) |
|
55 | 55 | { |
56 | - if ( !isset($model[$key]) ) |
|
56 | + if (!isset($model[$key])) |
|
57 | 57 | { |
58 | 58 | throw new \RuntimeException('The required argument "'.$key.'" was not provided for '.get_called_class()); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Assign the name of the component as the id if no id was specified |
63 | - if( !isset($model['id']) ) |
|
63 | + if (!isset($model['id'])) |
|
64 | 64 | { |
65 | 65 | $model['id'] = $model['name']; |
66 | 66 | } |
67 | 67 | |
68 | - $this->model = array_merge( $this->default_model(), $model ); |
|
68 | + $this->model = array_merge($this->default_model(), $model); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |