@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function required_parameters() |
23 | 23 | { |
24 | - return array('name','data'); |
|
24 | + return array('name', 'data'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function get_script_path() |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | if( !in_array($type, $this->registered_components) ) |
48 | 48 | { |
49 | 49 | $this->registered_components[$type] = $class_name; |
50 | + } else { |
|
51 | + throw new \RuntimeException("A component of type '$type' has already been registered."); |
|
50 | 52 | } |
51 | - else throw new \RuntimeException("A component of type '$type' has already been registered."); |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | /** |
@@ -85,8 +86,7 @@ discard block |
||
85 | 86 | if( file_exists( $file_name ) ) |
86 | 87 | { |
87 | 88 | require_once $file_name; |
88 | - } |
|
89 | - else |
|
89 | + } else |
|
90 | 90 | { |
91 | 91 | throw new \RuntimeException("A component of type '$type' does not exist."); |
92 | 92 | } |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @param array $model |
20 | 20 | */ |
21 | - public function __construct( array $model = array() ) |
|
21 | + public function __construct(array $model = array()) |
|
22 | 22 | { |
23 | 23 | // Check that the required parameters are provided. |
24 | - foreach( $this->required_parameters() as $key ) |
|
24 | + foreach ($this->required_parameters() as $key) |
|
25 | 25 | { |
26 | - if ( !isset($model[$key]) ) |
|
26 | + if (!isset($model[$key])) |
|
27 | 27 | { |
28 | 28 | throw new \RuntimeException('The required parameter "'.$key.'" was not provided for '.get_called_class()); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | - $this->model = array_merge( $this->default_model(), $model ); |
|
32 | + $this->model = array_merge($this->default_model(), $model); |
|
33 | 33 | |
34 | 34 | $this->on_created(); |
35 | 35 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return mixed the parameter's value. |
43 | 43 | */ |
44 | - public function __get( $name ) |
|
44 | + public function __get($name) |
|
45 | 45 | { |
46 | - if( isset( $this->model[$name] ) ) |
|
46 | + if (isset($this->model[$name])) |
|
47 | 47 | { |
48 | 48 | return $this->model[$name]; |
49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return mixed the settings' parameter value. |
59 | 59 | */ |
60 | - public function __set( $name, $value ) |
|
60 | + public function __set($name, $value) |
|
61 | 61 | { |
62 | 62 | $this->model[$name] = $value; |
63 | 63 | } |
@@ -69,22 +69,22 @@ discard block |
||
69 | 69 | * @throws TemplateNotFoundException Thrown if the template file can |
70 | 70 | * not found. |
71 | 71 | */ |
72 | - public function render( $echo = false ){ |
|
72 | + public function render($echo = false) { |
|
73 | 73 | |
74 | 74 | $rendered_html = ''; |
75 | 75 | |
76 | - if( file_exists( $this->get_script_path() ) ) |
|
76 | + if (file_exists($this->get_script_path())) |
|
77 | 77 | { |
78 | 78 | ob_start(); |
79 | - include( $this->get_script_path() ); |
|
79 | + include($this->get_script_path()); |
|
80 | 80 | $rendered_html = ob_get_clean(); |
81 | 81 | } |
82 | 82 | else |
83 | 83 | { |
84 | - throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_script_path() ); |
|
84 | + throw new \RuntimeException("Error: cannot render HTML, template file not found at ".$this->get_script_path()); |
|
85 | 85 | } |
86 | 86 | |
87 | - if( !$echo ) |
|
87 | + if (!$echo) |
|
88 | 88 | { |
89 | 89 | return $rendered_html; |
90 | 90 | } |