Completed
Push — master ( 40dd7e...579edf )
by Askupa
01:50
created
components/select/controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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() 
Please login to merge, or discard this patch.
AbstractComponent.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Renderer.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public static function get_instance()
20 20
     {
21
-        if( null === static::$instance ) 
21
+        if (null === static::$instance) 
22 22
         {
23 23
             static::$instance = new static();
24 24
         }
25 25
         return static::$instance;
26 26
     }
27 27
 
28
-    public function render_component( $type, array $props = array() )
28
+    public function render_component($type, array $props = array())
29 29
     {
30
-        $component = $this->create_component( $type, $props );
30
+        $component = $this->create_component($type, $props);
31 31
         return $component->render();
32 32
     }
33 33
 
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
      * @param string $class_name
43 43
      * @throws \RuntimeException
44 44
      */
45
-    public function register_component( $type, $class_name )
45
+    public function register_component($type, $class_name)
46 46
     {
47
-        if( !in_array($type, $this->registered_components) )
47
+        if (!in_array($type, $this->registered_components))
48 48
         {
49 49
             $this->registered_components[$type] = $class_name;
50 50
         }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
      * @param type $props
58 58
      * @return type
59 59
      */
60
-    private function create_component( $type, $props )
60
+    private function create_component($type, $props)
61 61
     {
62 62
         try {
63
-            $component = $this->create_registered_component ($type, $props );
63
+            $component = $this->create_registered_component($type, $props);
64 64
         } catch (\RuntimeException $ex) {
65
-            $component = $this->create_core_component ($type, $props );
65
+            $component = $this->create_core_component($type, $props);
66 66
         }
67 67
         
68 68
         return $component;
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
      * @param type $props
75 75
      * @throws \RuntimeException
76 76
      */
77
-    private function create_core_component( $type, $props )
77
+    private function create_core_component($type, $props)
78 78
     {
79 79
         $file_name  = __DIR__."/components/$type/controller.php";
80 80
         $class_name = 'Amarkal\\UI\\Component_'.$type;
81 81
         
82 82
         // Load one of the core components
83
-        if(!class_exists($class_name))
83
+        if (!class_exists($class_name))
84 84
         {
85
-            if( file_exists( $file_name ) ) 
85
+            if (file_exists($file_name)) 
86 86
             {
87 87
                 require_once $file_name;
88 88
             }
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      * @param type $props
102 102
      * @throws \RuntimeException
103 103
      */
104
-    private function create_registered_component( $type, $props )
104
+    private function create_registered_component($type, $props)
105 105
     {
106
-        if(in_array($type, $this->registered_components))
106
+        if (in_array($type, $this->registered_components))
107 107
         {
108 108
             $class_name = $this->registered_components[$type];
109 109
             return new $class_name($props);
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
AbstractController.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
functions.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Prevent direct file access
15
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
15
+defined('ABSPATH') or die('No script kiddies please!');
16 16
 
17 17
 /**
18 18
  * Prevent loading the library more than once
19 19
  */
20
-if( defined( 'AMARKAL_UI' ) ) return false;
21
-define( 'AMARKAL_UI', true );
20
+if (defined('AMARKAL_UI')) return false;
21
+define('AMARKAL_UI', true);
22 22
 
23
-if(!function_exists('amarkal_ui_render'))
23
+if (!function_exists('amarkal_ui_render'))
24 24
 {
25 25
     /**
26 26
      * Render a UI component.
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
      * @param array $props The component's properties
31 31
      * @return string The rendered HTML
32 32
      */
33
-    function amarkal_ui_render( $type, array $props = array() )
33
+    function amarkal_ui_render($type, array $props = array())
34 34
     {
35 35
         $renderer = Amarkal\UI\Renderer::get_instance();
36
-        return $renderer->render_component( $type, $props );
36
+        return $renderer->render_component($type, $props);
37 37
     }
38 38
 }
39 39
 
40
-if(!function_exists('amarkal_ui_register_component'))
40
+if (!function_exists('amarkal_ui_register_component'))
41 41
 {
42 42
     /**
43 43
      * Register a custom UI component. The registered component's class should
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      * to one of the core component's type, it will override the core component.
48 48
      * @param string $class_name The component's class name.
49 49
      */
50
-    function amarkal_ui_register_component( $type, $class_name )
50
+    function amarkal_ui_register_component($type, $class_name)
51 51
     {
52 52
         $renderer = Amarkal\UI\Renderer::get_instance();
53
-        $renderer->register_component( $type, $class_name );
53
+        $renderer->register_component($type, $class_name);
54 54
     }
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@
 block discarded – undo
17 17
 /**
18 18
  * Prevent loading the library more than once
19 19
  */
20
-if( defined( 'AMARKAL_UI' ) ) return false;
20
+if( defined( 'AMARKAL_UI' ) ) {
21
+    return false;
22
+}
21 23
 define( 'AMARKAL_UI', true );
22 24
 
23 25
 if(!function_exists('amarkal_ui_render'))
Please login to merge, or discard this patch.
composer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 // Load module functions
12 12
 require_once 'functions.php';
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
bootstrap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 /**
12 12
  * Load module functions. If this amarkal module has not been loaded, 
13 13
  * functions.php will not return false.
14 14
  */
15
-if(false !== (require_once 'functions.php'))
15
+if (false !== (require_once 'functions.php'))
16 16
 {
17 17
     // Load required classes if not using composer
18 18
     require_once 'Renderer.php';
Please login to merge, or discard this patch.