Completed
Push — master ( 4de9d8...5ac3d3 )
by Askupa
02:00
created
components/text/controller.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
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
     
Please login to merge, or discard this patch.
components/radio/controller.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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
     
Please login to merge, or discard this patch.
ComponentFactory.php 3 patches
Doc Comments   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,6 +50,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 )
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
AbstractComponent.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * 
34 34
      * @param array $model
35 35
      */
36
-    public function __construct( array $model = array() ) 
36
+    public function __construct(array $model = array()) 
37 37
     {
38 38
         parent::__construct($model);
39 39
         
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
      * 
75 75
      * @return array
76 76
      */
77
-    public function set_model( $model )
77
+    public function set_model($model)
78 78
     {
79 79
         // Check that the required arguments are provided.
80
-        foreach( $this->required_arguments() as $key )
80
+        foreach ($this->required_arguments() as $key)
81 81
         {
82
-            if ( !isset($model[$key]) )
82
+            if (!isset($model[$key]))
83 83
             {
84 84
                 throw new \RuntimeException('The required argument "'.$key.'" was not provided for '.get_called_class());
85 85
             }
86 86
         }
87 87
         
88 88
         // Assign the name of the component as the id if no id was specified
89
-        if( !isset($model['id']) )
89
+        if (!isset($model['id']))
90 90
         {
91 91
             $model['id'] = $model['name'];
92 92
         }
93 93
         
94
-        $this->model = array_merge( $this->default_model(), $model );
94
+        $this->model = array_merge($this->default_model(), $model);
95 95
     }
96 96
     
97 97
     /**
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
      * 
111 111
      * @param string $class
112 112
      */
113
-    public function add_html_class( $class )
113
+    public function add_html_class($class)
114 114
     {
115
-        if( !in_array($class, $this->html_classes) )
115
+        if (!in_array($class, $this->html_classes))
116 116
         {
117 117
             $this->html_classes[] = $class;
118 118
         }
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
      * 
125 125
      * @param string $class
126 126
      */
127
-    public function remove_html_class( $class )
127
+    public function remove_html_class($class)
128 128
     {
129 129
         $i = 0;
130
-        foreach( $this->html_classes as $c )
130
+        foreach ($this->html_classes as $c)
131 131
         {
132
-            if( $c === $class )
132
+            if ($c === $class)
133 133
             {
134
-                array_splice($this->html_classes,$i,1);
134
+                array_splice($this->html_classes, $i, 1);
135 135
                 break;
136 136
             }
137 137
             $i++;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      * 
144 144
      * @param type $validity
145 145
      */
146
-    Public function set_validity( $validity )
146
+    Public function set_validity($validity)
147 147
     {
148 148
         $this->validity = $validity;
149
-        if($validity === $this::INVALID)
149
+        if ($validity === $this::INVALID)
150 150
         {
151 151
             $this->add_html_class('amarkal-ui-component-error');
152 152
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * 
170 170
      * {@inheritdoc}
171 171
      */
172
-    public function render( $echo = false )
172
+    public function render($echo = false)
173 173
     {
174 174
         $this->enqueue_scripts();
175 175
         return parent::render($echo);
Please login to merge, or discard this patch.