Passed
Push — main ( 532590...120ebc )
by Sammy
01:27
created
TableToForm.class.php 2 patches
Braces   +37 added lines, -41 removed lines patch added patch discarded remove patch
@@ -9,11 +9,13 @@  discard block
 block discarded – undo
9 9
 {
10 10
   private static function compute_field_value($model,$field_name)
11 11
   {
12
-    if(method_exists($model,$field_name))
13
-      return $model->$field_name();
12
+    if(method_exists($model,$field_name)) {
13
+          return $model->$field_name();
14
+    }
14 15
 
15
-    if(property_exists($model,$field_name))
16
-      return $model->$field_name;
16
+    if(property_exists($model,$field_name)) {
17
+          return $model->$field_name;
18
+    }
17 19
 
18 20
     return '';
19 21
   }
@@ -51,74 +53,66 @@  discard block
 block discarded – undo
51 53
 
52 54
     $table = get_class($model)::table();
53 55
 
54
-    if(is_null($table->column($field_name)))
55
-      return Form::input($field_name,$field_value,$attributes,$errors);
56
+    if(is_null($table->column($field_name))) {
57
+          return Form::input($field_name,$field_value,$attributes,$errors);
58
+    }
56 59
 
57 60
     $ret = '';
58 61
 
59 62
     $field = $table->column($field_name);
60 63
 
61 64
 
62
-    if(isset($attributes['required']) && $attributes['required'] === false)
63
-      unset($attributes['required']);
64
-
65
-    elseif(!$field->is_nullable())
66
-      $attributes[] = 'required';
65
+    if(isset($attributes['required']) && $attributes['required'] === false) {
66
+          unset($attributes['required']);
67
+    } elseif(!$field->is_nullable()) {
68
+          $attributes[] = 'required';
69
+    }
67 70
 
68 71
     if($field->is_auto_incremented())
69 72
     {
70 73
       $ret .= Form::hidden($field->name(),$field_value);
71
-    }
72
-    elseif($field->type()->is_boolean())
74
+    } elseif($field->type()->is_boolean())
73 75
     {
74 76
       $option_list = $attributes['values'] ?? [0 => 0, 1 => 1];
75 77
       $ret .= Form::select($field->name(), $option_list ,$field_value, $attributes); //
76
-    }
77
-    elseif($field->type()->is_integer())
78
+    } elseif($field->type()->is_integer())
78 79
     {
79 80
       $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
80
-    }
81
-    elseif($field->type()->is_year())
81
+    } elseif($field->type()->is_year())
82 82
     {
83 83
       $attributes['size'] = $attributes['maxlength'] = 4;
84 84
       $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
85
-    }
86
-    elseif($field->type()->is_date())
85
+    } elseif($field->type()->is_date())
87 86
     {
88 87
       $ret .= Form::date($field->name(),$field_value,$attributes,$errors);
89
-    }
90
-    elseif($field->type()->is_time())
88
+    } elseif($field->type()->is_time())
91 89
     {
92 90
       $ret .= Form::time($field->name(),$field_value,$attributes,$errors);
93
-    }
94
-    elseif($field->type()->is_datetime())
91
+    } elseif($field->type()->is_datetime())
95 92
     {
96 93
       $ret .= Form::datetime($field->name(),$field_value,$attributes,$errors);
97
-    }
98
-    elseif($field->type()->is_text())
94
+    } elseif($field->type()->is_text())
99 95
     {
100 96
       $ret .= Form::textarea($field->name(),$field_value,$attributes,$errors);
101
-    }
102
-    elseif($field->type()->is_enum())
97
+    } elseif($field->type()->is_enum())
103 98
     {
104 99
 
105 100
       $enum_values = [];
106
-      foreach($field->type()->enum_values() as $e_val)
107
-        $enum_values[$e_val] = $e_val;
101
+      foreach($field->type()->enum_values() as $e_val) {
102
+              $enum_values[$e_val] = $e_val;
103
+      }
108 104
 
109 105
       $selected = $attributes['value'] ?? $field_value ?? '';
110 106
       // foreach($field->)
111 107
       $ret .= Form::select($field->name(), $enum_values, $selected, $attributes); //
112 108
 
113 109
       // throw new \Exception('ENUM IS NOT HANDLED BY TableToFom');
114
-    }
115
-    elseif($field->type()->is_string())
110
+    } elseif($field->type()->is_string())
116 111
     {
117 112
       $max_length = $field->type()->length();
118 113
       $attributes['size'] = $attributes['maxlength'] = $max_length;
119 114
       $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
120
-    }
121
-    else
115
+    } else
122 116
     {
123 117
       $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
124 118
     }
@@ -130,8 +124,9 @@  discard block
 block discarded – undo
130 124
   public static function field_with_label($model,$field_name,$attributes=[],$errors=[]) : string
131 125
   {
132 126
     $field_attributes = $attributes;
133
-    if(isset($attributes['label']))
134
-      unset($field_attributes['label']);
127
+    if(isset($attributes['label'])) {
128
+          unset($field_attributes['label']);
129
+    }
135 130
 
136 131
     return sprintf('%s %s', self::label($model,$field_name,$attributes,$errors), self::field($model,$field_name,$field_attributes,$errors));
137 132
   }
@@ -148,14 +143,15 @@  discard block
 block discarded – undo
148 143
       $form_field = '';
149 144
       if($column->is_auto_incremented())
150 145
       {
151
-        if(!$model->is_new())
152
-          $form_field = self::field($model,$column_name);
153
-      }
154
-      else
146
+        if(!$model->is_new()) {
147
+                  $form_field = self::field($model,$column_name);
148
+        }
149
+      } else
155 150
       {
156 151
         $form_field = self::field_with_label($model,$column_name);
157
-        if(!is_null($group_class))
158
-          $form_field = new Element('div',$form_field, ['class' => $group_class]);
152
+        if(!is_null($group_class)) {
153
+                  $form_field = new Element('div',$form_field, ['class' => $group_class]);
154
+        }
159 155
       }
160 156
       $ret .= PHP_EOL.$form_field;
161 157
     }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -3,26 +3,26 @@  discard block
 block discarded – undo
3 3
 namespace HexMakina\kadro;
4 4
 
5 5
 use \HexMakina\Crudites\Interfaces\ModelInterface;
6
-use \HexMakina\Marker\{Form,Element};
6
+use \HexMakina\Marker\{Form, Element};
7 7
 
8 8
 class TableToForm
9 9
 {
10
-  private static function compute_field_value($model,$field_name)
10
+  private static function compute_field_value($model, $field_name)
11 11
   {
12
-    if(method_exists($model,$field_name))
12
+    if (method_exists($model, $field_name))
13 13
       return $model->$field_name();
14 14
 
15
-    if(property_exists($model,$field_name))
15
+    if (property_exists($model, $field_name))
16 16
       return $model->$field_name;
17 17
 
18 18
     return '';
19 19
   }
20 20
 
21
-  public static function label($model,$field_name,$attributes=[],$errors=[])
21
+  public static function label($model, $field_name, $attributes = [], $errors = [])
22 22
   {
23 23
     $label_content = $field_name;
24 24
 
25
-    if(isset($attributes['label']))
25
+    if (isset($attributes['label']))
26 26
     {
27 27
       $label_content = $attributes['label'];
28 28
       unset($attributes['label']);
@@ -44,66 +44,66 @@  discard block
 block discarded – undo
44 44
     return $ret;
45 45
   }
46 46
 
47
-  public static function field(ModelInterface $model,$field_name,$attributes=[],$errors=[]) : string
47
+  public static function field(ModelInterface $model, $field_name, $attributes = [], $errors = []) : string
48 48
   {
49
-    $field_value = $attributes['value'] ?? self::compute_field_value($model,$field_name);
49
+    $field_value = $attributes['value'] ?? self::compute_field_value($model, $field_name);
50 50
     $attributes['name'] = $attributes['name'] ?? $field_name;
51 51
 
52 52
     $table = get_class($model)::table();
53 53
 
54
-    if(is_null($table->column($field_name)))
55
-      return Form::input($field_name,$field_value,$attributes,$errors);
54
+    if (is_null($table->column($field_name)))
55
+      return Form::input($field_name, $field_value, $attributes, $errors);
56 56
 
57 57
     $ret = '';
58 58
 
59 59
     $field = $table->column($field_name);
60 60
 
61 61
 
62
-    if(isset($attributes['required']) && $attributes['required'] === false)
62
+    if (isset($attributes['required']) && $attributes['required'] === false)
63 63
       unset($attributes['required']);
64 64
 
65
-    elseif(!$field->is_nullable())
65
+    elseif (!$field->is_nullable())
66 66
       $attributes[] = 'required';
67 67
 
68
-    if($field->is_auto_incremented())
68
+    if ($field->is_auto_incremented())
69 69
     {
70
-      $ret .= Form::hidden($field->name(),$field_value);
70
+      $ret .= Form::hidden($field->name(), $field_value);
71 71
     }
72
-    elseif($field->type()->is_boolean())
72
+    elseif ($field->type()->is_boolean())
73 73
     {
74 74
       $option_list = $attributes['values'] ?? [0 => 0, 1 => 1];
75
-      $ret .= Form::select($field->name(), $option_list ,$field_value, $attributes); //
75
+      $ret .= Form::select($field->name(), $option_list, $field_value, $attributes); //
76 76
     }
77
-    elseif($field->type()->is_integer())
77
+    elseif ($field->type()->is_integer())
78 78
     {
79
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
79
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
80 80
     }
81
-    elseif($field->type()->is_year())
81
+    elseif ($field->type()->is_year())
82 82
     {
83 83
       $attributes['size'] = $attributes['maxlength'] = 4;
84
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
84
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
85 85
     }
86
-    elseif($field->type()->is_date())
86
+    elseif ($field->type()->is_date())
87 87
     {
88
-      $ret .= Form::date($field->name(),$field_value,$attributes,$errors);
88
+      $ret .= Form::date($field->name(), $field_value, $attributes, $errors);
89 89
     }
90
-    elseif($field->type()->is_time())
90
+    elseif ($field->type()->is_time())
91 91
     {
92
-      $ret .= Form::time($field->name(),$field_value,$attributes,$errors);
92
+      $ret .= Form::time($field->name(), $field_value, $attributes, $errors);
93 93
     }
94
-    elseif($field->type()->is_datetime())
94
+    elseif ($field->type()->is_datetime())
95 95
     {
96
-      $ret .= Form::datetime($field->name(),$field_value,$attributes,$errors);
96
+      $ret .= Form::datetime($field->name(), $field_value, $attributes, $errors);
97 97
     }
98
-    elseif($field->type()->is_text())
98
+    elseif ($field->type()->is_text())
99 99
     {
100
-      $ret .= Form::textarea($field->name(),$field_value,$attributes,$errors);
100
+      $ret .= Form::textarea($field->name(), $field_value, $attributes, $errors);
101 101
     }
102
-    elseif($field->type()->is_enum())
102
+    elseif ($field->type()->is_enum())
103 103
     {
104 104
 
105 105
       $enum_values = [];
106
-      foreach($field->type()->enum_values() as $e_val)
106
+      foreach ($field->type()->enum_values() as $e_val)
107 107
         $enum_values[$e_val] = $e_val;
108 108
 
109 109
       $selected = $attributes['value'] ?? $field_value ?? '';
@@ -112,50 +112,50 @@  discard block
 block discarded – undo
112 112
 
113 113
       // throw new \Exception('ENUM IS NOT HANDLED BY TableToFom');
114 114
     }
115
-    elseif($field->type()->is_string())
115
+    elseif ($field->type()->is_string())
116 116
     {
117 117
       $max_length = $field->type()->length();
118 118
       $attributes['size'] = $attributes['maxlength'] = $max_length;
119
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
119
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
120 120
     }
121 121
     else
122 122
     {
123
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
123
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
124 124
     }
125 125
 
126 126
 
127 127
     return $ret;
128 128
   }
129 129
 
130
-  public static function field_with_label($model,$field_name,$attributes=[],$errors=[]) : string
130
+  public static function field_with_label($model, $field_name, $attributes = [], $errors = []) : string
131 131
   {
132 132
     $field_attributes = $attributes;
133
-    if(isset($attributes['label']))
133
+    if (isset($attributes['label']))
134 134
       unset($field_attributes['label']);
135 135
 
136
-    return sprintf('%s %s', self::label($model,$field_name,$attributes,$errors), self::field($model,$field_name,$field_attributes,$errors));
136
+    return sprintf('%s %s', self::label($model, $field_name, $attributes, $errors), self::field($model, $field_name, $field_attributes, $errors));
137 137
   }
138 138
 
139 139
 
140
-  public static function fields(ModelInterface $model,$group_class=null) : string
140
+  public static function fields(ModelInterface $model, $group_class = null) : string
141 141
   {
142 142
     $table = get_class($model)::table();
143 143
     $ret = '';
144
-    foreach($table->columns() as $column_name => $column)
144
+    foreach ($table->columns() as $column_name => $column)
145 145
     {
146 146
       // vd($column_name);
147 147
 
148 148
       $form_field = '';
149
-      if($column->is_auto_incremented())
149
+      if ($column->is_auto_incremented())
150 150
       {
151
-        if(!$model->is_new())
152
-          $form_field = self::field($model,$column_name);
151
+        if (!$model->is_new())
152
+          $form_field = self::field($model, $column_name);
153 153
       }
154 154
       else
155 155
       {
156
-        $form_field = self::field_with_label($model,$column_name);
157
-        if(!is_null($group_class))
158
-          $form_field = new Element('div',$form_field, ['class' => $group_class]);
156
+        $form_field = self::field_with_label($model, $column_name);
157
+        if (!is_null($group_class))
158
+          $form_field = new Element('div', $form_field, ['class' => $group_class]);
159 159
       }
160 160
       $ret .= PHP_EOL.$form_field;
161 161
     }
Please login to merge, or discard this patch.
Models/Lingvo.class.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
     return $this->iso_name().' ('.$this->Part3.')';
32 32
   }
33 33
 
34
-	public function traceable() : bool
35
-	{
36
-		return false;
37
-	}
34
+  public function traceable() : bool
35
+  {
36
+    return false;
37
+  }
38 38
 
39 39
   public function iso_name()
40 40
   {
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
   public static function search_language($term, $authority=null)
103 103
   {
104 104
     $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass();
105
-		$ret = [];
106
-		foreach($rows as $row)
107
-		   $ret[$row[self::ISO_3]] = $row[self::ISO_NAME];
105
+    $ret = [];
106
+    foreach($rows as $row)
107
+        $ret[$row[self::ISO_3]] = $row[self::ISO_NAME];
108 108
 
109 109
     return $ret;
110 110
   }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,8 +103,9 @@  discard block
 block discarded – undo
103 103
   {
104 104
     $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass();
105 105
 		$ret = [];
106
-		foreach($rows as $row)
107
-		   $ret[$row[self::ISO_3]] = $row[self::ISO_NAME];
106
+		foreach($rows as $row) {
107
+				   $ret[$row[self::ISO_3]] = $row[self::ISO_NAME];
108
+		}
108 109
 
109 110
     return $ret;
110 111
   }
@@ -115,8 +116,10 @@  discard block
 block discarded – undo
115 116
     $Query->aw_eq(self::ISO_3, $code);
116 117
     $rows = $Query->ret_col();
117 118
 
118
-    if(isset($rows[0])) // only 1 result
119
+    if(isset($rows[0])) {
120
+      // only 1 result
119 121
       return current($rows);
122
+    }
120 123
 
121 124
     return null; // no results
122 125
   }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,39 +52,39 @@  discard block
 block discarded – undo
52 52
   }
53 53
 
54 54
 
55
-  public static function query_retrieve($filter=[], $options=[]) : SelectInterface
55
+  public static function query_retrieve($filter = [], $options = []) : SelectInterface
56 56
   {
57 57
 
58 58
     $searchable_fields = [self::ISO_NAME, self::ISO_3, self::ISO_2B, self::ISO_2T, self::ISO_1];
59 59
 
60 60
     $Query = static::table()->select();
61 61
 
62
-    if(isset($filter['name']))
62
+    if (isset($filter['name']))
63 63
     {
64 64
 
65 65
     }
66 66
 
67
-    if(isset($filter['code']))
67
+    if (isset($filter['code']))
68 68
     {
69 69
 
70 70
     }
71 71
 
72
-    if(isset($filter['term']))
72
+    if (isset($filter['term']))
73 73
     {
74 74
       $Query->aw_filter_content(['term' => $filter['term'], 'fields' => $searchable_fields], $Query->table_label(), 'OR');
75 75
     }
76 76
 
77
-    if(isset($filter['requires_authority']) && isset(self::ISO_SETS[$filter['requires_authority']]))
77
+    if (isset($filter['requires_authority']) && isset(self::ISO_SETS[$filter['requires_authority']]))
78 78
     {
79 79
       $Query->aw_not_empty($filter['requires_authority']);
80 80
     }
81 81
 
82
-    if(isset($filter['types']))
82
+    if (isset($filter['types']))
83 83
     {
84 84
       $wc = sprintf('AND Type IN (\'%s\') ', implode('\', \'', array_keys(self::types())));
85 85
       $Query->and_where($wc);
86 86
     }
87
-    if(isset($filter['scopes']))
87
+    if (isset($filter['scopes']))
88 88
     {
89 89
       $wc = sprintf('AND Scope IN (\'%s\') ', implode('\', \'', array_keys(self::scopes())));
90 90
       $Query->and_where($wc);
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     return $Query;
100 100
   }
101 101
 
102
-  public static function search_language($term, $authority=null)
102
+  public static function search_language($term, $authority = null)
103 103
   {
104 104
     $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass();
105 105
 		$ret = [];
106
-		foreach($rows as $row)
106
+		foreach ($rows as $row)
107 107
 		   $ret[$row[self::ISO_3]] = $row[self::ISO_NAME];
108 108
 
109 109
     return $ret;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     $Query->aw_eq(self::ISO_3, $code);
116 116
     $rows = $Query->ret_col();
117 117
 
118
-    if(isset($rows[0])) // only 1 result
118
+    if (isset($rows[0])) // only 1 result
119 119
       return current($rows);
120 120
 
121 121
     return null; // no results
Please login to merge, or discard this patch.
Models/Traduko.class.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
   const TABLE_NAME = 'kadro_traduki';
11 11
   const TABLE_ALIAS = 'traduko';
12 12
 
13
-	public function traceable() : bool
14
-	{
15
-		return false;
16
-	}
13
+  public function traceable() : bool
14
+  {
15
+    return false;
16
+  }
17 17
   
18 18
   public function immortal() : bool
19 19
   {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     return false;
21 21
   }
22 22
 
23
-  public static function query_retrieve($filters=[], $options=[]) : SelectInterface
23
+  public static function query_retrieve($filters = [], $options = []) : SelectInterface
24 24
   {
25 25
     $Query = static::table()->select();
26 26
     $Query->order_by(['kategorio', 'ASC']);
Please login to merge, or discard this patch.
Models/Abilities/Event.class.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,22 +23,22 @@
 block discarded – undo
23 23
 
24 24
   public static function today($format=Dato::FORMAT)
25 25
   {
26
-		return Dato::today($format);
27
-	}
26
+    return Dato::today($format);
27
+  }
28 28
 
29 29
   public static function date($date=null, $format=Dato::FORMAT) : string
30
-	{
31
-		return Dato::format($date);
32
-	}
30
+  {
31
+    return Dato::format($date);
32
+  }
33 33
   //
34 34
   // //------------------------------------------------------------  MySQL DateTime helpers
35 35
   // public static function year($date=null) : string
36
-	// {
37
-	// 	return Dato::format($date, Dato::FORMAT_YEAR);
38
-	// }
36
+  // {
37
+  // 	return Dato::format($date, Dato::FORMAT_YEAR);
38
+  // }
39 39
   //
40
-	// public static function datetime($date=null) : string
41
-	// {
42
-	// 	return DatoTempo::format($date);
43
-	// }
40
+  // public static function datetime($date=null) : string
41
+  // {
42
+  // 	return DatoTempo::format($date);
43
+  // }
44 44
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     return $this->__toString();
22 22
   }
23 23
 
24
-  public static function today($format=Dato::FORMAT)
24
+  public static function today($format = Dato::FORMAT)
25 25
   {
26 26
 		return Dato::today($format);
27 27
 	}
28 28
 
29
-  public static function date($date=null, $format=Dato::FORMAT) : string
29
+  public static function date($date = null, $format = Dato::FORMAT) : string
30 30
 	{
31 31
 		return Dato::format($date);
32 32
 	}
Please login to merge, or discard this patch.
Container/LeMarchand.class.php 2 patches
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -34,11 +34,13 @@  discard block
 block discarded – undo
34 34
   public function get($configuration)
35 35
   {
36 36
     
37
-    if(!is_string($configuration))
38
-      throw new LamentException($configuration);
37
+    if(!is_string($configuration)) {
38
+          throw new LamentException($configuration);
39
+    }
39 40
 
40
-    if($this->has($configuration))
41
-      return $this->configurations[$configuration];
41
+    if($this->has($configuration)) {
42
+          return $this->configurations[$configuration];
43
+    }
42 44
 
43 45
     
44 46
     // fallbacks
@@ -47,17 +49,19 @@  discard block
 block discarded – undo
47 49
       $ret = $this->configurations;
48 50
       foreach(explode('.', $configuration) as $k)
49 51
       {
50
-        if(!isset($ret[$k]))
51
-          throw new ConfigurationException($configuration);
52
+        if(!isset($ret[$k])) {
53
+                  throw new ConfigurationException($configuration);
54
+        }
52 55
         $ret = $ret[$k];
53 56
       }
54 57
 
55 58
       return $ret;
56
-    }
57
-    elseif(class_exists($configuration)) // auto create instances
59
+    } elseif(class_exists($configuration)) {
60
+      // auto create instances
58 61
     {
59 62
       
60 63
       $rc = new \ReflectionClass($configuration);
64
+    }
61 65
 
62 66
       $construction_args = [];
63 67
       $instance = null;
@@ -68,12 +72,13 @@  discard block
 block discarded – undo
68 72
           $construction_args []= $this->get($param->getType().'');
69 73
         }
70 74
         $instance = $rc->newInstanceArgs($construction_args);
75
+      } else {
76
+              $instance = $rc->newInstanceArgs();
71 77
       }
72
-      else 
73
-        $instance = $rc->newInstanceArgs();
74 78
 
75
-      if($rc->hasMethod('set_container'))
76
-        $instance->set_container($this);
79
+      if($rc->hasMethod('set_container')) {
80
+              $instance->set_container($this);
81
+      }
77 82
       
78 83
       return $instance;
79 84
     }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   public function __debugInfo() : array
17 17
   {
18 18
     $dbg = get_object_vars($this);
19
-    $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine'])? get_class($dbg['configurations']['template_engine']) : 'NOT SET';
19
+    $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine']) ? get_class($dbg['configurations']['template_engine']) : 'NOT SET';
20 20
 
21 21
     return $dbg;
22 22
   }
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
   public function get($configuration)
35 35
   {
36 36
     
37
-    if(!is_string($configuration))
37
+    if (!is_string($configuration))
38 38
       throw new LamentException($configuration);
39 39
 
40
-    if($this->has($configuration))
40
+    if ($this->has($configuration))
41 41
       return $this->configurations[$configuration];
42 42
 
43 43
     
44 44
     // fallbacks
45
-    if(preg_match('/^settings\./', $configuration, $m) === 1)
45
+    if (preg_match('/^settings\./', $configuration, $m) === 1)
46 46
     {
47 47
       $ret = $this->configurations;
48
-      foreach(explode('.', $configuration) as $k)
48
+      foreach (explode('.', $configuration) as $k)
49 49
       {
50
-        if(!isset($ret[$k]))
50
+        if (!isset($ret[$k]))
51 51
           throw new ConfigurationException($configuration);
52 52
         $ret = $ret[$k];
53 53
       }
54 54
 
55 55
       return $ret;
56 56
     }
57
-    elseif(class_exists($configuration)) // auto create instances
57
+    elseif (class_exists($configuration)) // auto create instances
58 58
     {
59 59
       
60 60
       $rc = new \ReflectionClass($configuration);
61 61
 
62 62
       $construction_args = [];
63 63
       $instance = null;
64
-      if(!is_null($rc->getConstructor()))
64
+      if (!is_null($rc->getConstructor()))
65 65
       {
66
-        foreach($rc->getConstructor()->getParameters() as $param)
66
+        foreach ($rc->getConstructor()->getParameters() as $param)
67 67
         {
68
-          $construction_args []= $this->get($param->getType().'');
68
+          $construction_args [] = $this->get($param->getType().'');
69 69
         }
70 70
         $instance = $rc->newInstanceArgs($construction_args);
71 71
       }
72 72
       else 
73 73
         $instance = $rc->newInstanceArgs();
74 74
 
75
-      if($rc->hasMethod('set_container'))
75
+      if ($rc->hasMethod('set_container'))
76 76
         $instance->set_container($this);
77 77
       
78 78
       return $instance;
Please login to merge, or discard this patch.
Controllers/Interfaces/CRUDController.class.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 interface CRUDController
6 6
 {
7
-   public function dashboard();
8
-   public function edit();
9
-   public function save();
10
-   public function listing();
7
+    public function dashboard();
8
+    public function edit();
9
+    public function save();
10
+    public function listing();
11 11
 
12
-   public function destroy();
12
+    public function destroy();
13 13
 
14
-   public function errors() : array;
14
+    public function errors() : array;
15 15
 }
16 16
 
17 17
 
Please login to merge, or discard this patch.
Controllers/TradukoController.class.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
     return $this->router()->prehop('traduko');
20 20
   }
21 21
 
22
-  public function update_file($lang='fra')
22
+  public function update_file($lang = 'fra')
23 23
   {
24
-    try{
24
+    try {
25 25
       $locale_path = $this->box('settings.locale.directory_path').'/'.$this->box('settings.locale.file_name');
26 26
       self::create_file($locale_path, $lang);
27 27
 
28 28
       $this->logger()->nice(L('KADRO_SYSTEM_FILE_UPDATED'));
29 29
     }
30
-    catch(\Exception $e)
30
+    catch (\Exception $e)
31 31
     {
32 32
       $this->logger()->notice(L('KADRO_SYSTEM_FILE_UPDATED'));
33 33
     }
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
   {
39 39
     $res = Traduko::filter(['lang' => $lang]);
40 40
     $assoc = [];
41
-    foreach($res as $id => $trad)
41
+    foreach ($res as $id => $trad)
42 42
     {
43
-      if(!isset($assoc[$trad->kategorio]))
43
+      if (!isset($assoc[$trad->kategorio]))
44 44
         $assoc[$trad->kategorio] = [];
45
-      if(!isset($assoc[$trad->kategorio][$trad->sekcio]))
45
+      if (!isset($assoc[$trad->kategorio][$trad->sekcio]))
46 46
         $assoc[$trad->kategorio][$trad->sekcio] = [];
47 47
 
48 48
       $assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang;
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
   public static function init($locale_path)
58 58
   {
59 59
     $languages = array_keys(array_slice(Traduko::inspect(Traduko::table_name())->columns(), 4));
60
-    foreach($languages as $l)
61
-      self::create_file($locale_path,$l);
60
+    foreach ($languages as $l)
61
+      self::create_file($locale_path, $l);
62 62
 
63 63
     return $languages;
64 64
   }
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
       self::create_file($locale_path, $lang);
27 27
 
28 28
       $this->logger()->nice(L('KADRO_SYSTEM_FILE_UPDATED'));
29
-    }
30
-    catch(\Exception $e)
29
+    } catch(\Exception $e)
31 30
     {
32 31
       $this->logger()->notice(L('KADRO_SYSTEM_FILE_UPDATED'));
33 32
     }
@@ -40,10 +39,12 @@  discard block
 block discarded – undo
40 39
     $assoc = [];
41 40
     foreach($res as $id => $trad)
42 41
     {
43
-      if(!isset($assoc[$trad->kategorio]))
44
-        $assoc[$trad->kategorio] = [];
45
-      if(!isset($assoc[$trad->kategorio][$trad->sekcio]))
46
-        $assoc[$trad->kategorio][$trad->sekcio] = [];
42
+      if(!isset($assoc[$trad->kategorio])) {
43
+              $assoc[$trad->kategorio] = [];
44
+      }
45
+      if(!isset($assoc[$trad->kategorio][$trad->sekcio])) {
46
+              $assoc[$trad->kategorio][$trad->sekcio] = [];
47
+      }
47 48
 
48 49
       $assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang;
49 50
     }
@@ -57,8 +58,9 @@  discard block
 block discarded – undo
57 58
   public static function init($locale_path)
58 59
   {
59 60
     $languages = array_keys(array_slice(Traduko::inspect(Traduko::table_name())->columns(), 4));
60
-    foreach($languages as $l)
61
-      self::create_file($locale_path,$l);
61
+    foreach($languages as $l) {
62
+          self::create_file($locale_path,$l);
63
+    }
62 64
 
63 65
     return $languages;
64 66
   }
Please login to merge, or discard this patch.
Controllers/OperatorController.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 namespace HexMakina\kadro\Controllers;
13 13
 
14 14
 use \HexMakina\Crudites\Crudites;
15
-use \HexMakina\kadro\Auth\{Operator,OperatorInterface,ACL,AccessRefusedException};
15
+use \HexMakina\kadro\Auth\{Operator, OperatorInterface, ACL, AccessRefusedException};
16 16
 
17 17
 
18 18
 class OperatorController extends \HexMakina\kadro\Controllers\ORMController
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     parent::edit();
24 24
 
25 25
     // do we create? or do we edit someone else ? must be admin
26
-    if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id())
26
+    if (is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id())
27 27
       $this->authorize('group_admin');
28 28
 
29 29
   }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
   public function save()
37 37
   {
38
-    if($this->operator()->operator_id() !== $this->form_model->operator_id())
38
+    if ($this->operator()->operator_id() !== $this->form_model->operator_id())
39 39
       $this->authorize('group_admin');
40 40
 
41 41
     parent::save();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
   public function before_save() : array
45 45
   {
46 46
     //------------------------------------------------------------- PASSWORDS
47
-    if($this->form_model->get('password') != $this->form_model->get('password_verification'))
47
+    if ($this->form_model->get('password') != $this->form_model->get('password_verification'))
48 48
     {
49 49
       $this->logger()->warning(L('KADRO_operator_ERR_PASSWORDS_MISMATCH'));
50 50
       return $this->edit();
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
   public function dashboard()
59 59
   {
60 60
     $real_operator_class = get_class($this->operator());
61
-    $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null,'username', 'ASC']]));
61
+    $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null, 'username', 'ASC']]));
62 62
   }
63 63
 
64 64
   public function destroy()
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
     parent::authorize('group_admin');
72 72
 
73 73
     $operator = Operator::one($this->router()->params());
74
-    if($operator->username() == $this->operator()->username())
74
+    if ($operator->username() == $this->operator()->username())
75 75
       throw new AccessRefusedException();
76 76
 
77
-    if(Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true)
77
+    if (Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true)
78 78
     {
79 79
       $confirmation_message = $operator->is_active() ? 'KADRO_operator_DISABLED' : 'KADRO_operator_ENABLED';
80 80
       $this->logger()->nice(L($confirmation_message, [$operator->name()]));
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
     parent::authorize('group_admin');
93 93
 
94 94
     $operator = Operator::one(['username' => $this->router()->params('username')]);
95
-    if($operator->username() == $this->operator()->username())
95
+    if ($operator->username() == $this->operator()->username())
96 96
       throw new AccessRefusedException();
97 97
 
98 98
     $permission_id = $this->router()->params('permission_id');
99 99
 
100 100
     $row_data = ['operator_id' => $operator->operator_id(), 'permission_id' => $permission_id];
101 101
     $row = ACL::table()->restore($row_data);
102
-    if($row->is_new())
102
+    if ($row->is_new())
103 103
     {
104 104
       $row = ACL::table()->produce($row_data);
105 105
       $res = $row->persist();
Please login to merge, or discard this patch.
Braces   +14 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
     parent::edit();
24 24
 
25 25
     // do we create? or do we edit someone else ? must be admin
26
-    if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id())
27
-      $this->authorize('group_admin');
26
+    if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id()) {
27
+          $this->authorize('group_admin');
28
+    }
28 29
 
29 30
   }
30 31
 
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
 
36 37
   public function save()
37 38
   {
38
-    if($this->operator()->operator_id() !== $this->form_model->operator_id())
39
-      $this->authorize('group_admin');
39
+    if($this->operator()->operator_id() !== $this->form_model->operator_id()) {
40
+          $this->authorize('group_admin');
41
+    }
40 42
 
41 43
     parent::save();
42 44
   }
@@ -71,15 +73,15 @@  discard block
 block discarded – undo
71 73
     parent::authorize('group_admin');
72 74
 
73 75
     $operator = Operator::one($this->router()->params());
74
-    if($operator->username() == $this->operator()->username())
75
-      throw new AccessRefusedException();
76
+    if($operator->username() == $this->operator()->username()) {
77
+          throw new AccessRefusedException();
78
+    }
76 79
 
77 80
     if(Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true)
78 81
     {
79 82
       $confirmation_message = $operator->is_active() ? 'KADRO_operator_DISABLED' : 'KADRO_operator_ENABLED';
80 83
       $this->logger()->nice(L($confirmation_message, [$operator->name()]));
81
-    }
82
-    else
84
+    } else
83 85
     {
84 86
       $this->logger()->warning(L('CRUDITES_ERR_QUERY_FAILED'));
85 87
     }
@@ -92,8 +94,9 @@  discard block
 block discarded – undo
92 94
     parent::authorize('group_admin');
93 95
 
94 96
     $operator = Operator::one(['username' => $this->router()->params('username')]);
95
-    if($operator->username() == $this->operator()->username())
96
-      throw new AccessRefusedException();
97
+    if($operator->username() == $this->operator()->username()) {
98
+          throw new AccessRefusedException();
99
+    }
97 100
 
98 101
     $permission_id = $this->router()->params('permission_id');
99 102
 
@@ -103,8 +106,7 @@  discard block
 block discarded – undo
103 106
     {
104 107
       $row = ACL::table()->produce($row_data);
105 108
       $res = $row->persist();
106
-    }
107
-    else
109
+    } else
108 110
     {
109 111
       $row->wipe();
110 112
     }
Please login to merge, or discard this patch.
Controllers/ReceptionController.class.php 2 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
   public function welcome(OperatorInterface $operator)
19 19
   {
20 20
 
21
-    if($this->router()->name() === 'identify')
22
-      $this->identify($operator);
21
+    if($this->router()->name() === 'identify') {
22
+          $this->identify($operator);
23
+    }
23 24
 
24 25
     $Controller = $this->router()->target_controller();
25 26
     $Controller = $this->box($Controller);
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 
28 29
     if($Controller->requires_operator())
29 30
     {
30
-      if(is_null($operator = get_class($operator)::exists($this->box('StateAgent')->operator_id())))
31
-        $this->router()->hop('checkin');
31
+      if(is_null($operator = get_class($operator)::exists($this->box('StateAgent')->operator_id()))) {
32
+              $this->router()->hop('checkin');
33
+      }
32 34
 
33 35
       if(!$operator->is_active())
34 36
       {
@@ -62,11 +64,13 @@  discard block
 block discarded – undo
62 64
 
63 65
       $operator = get_class($op)::exists(['username' => $username]);
64 66
 
65
-      if(is_null($operator) || !$operator->is_active())
66
-        throw new \Exception('ERR_DISABLED');
67
+      if(is_null($operator) || !$operator->is_active()) {
68
+              throw new \Exception('ERR_DISABLED');
69
+      }
67 70
 
68
-      if(!$operator->password_verify($password))
69
-        throw new \Exception('ERR_WRONG_LOGIN_OR_PASSWORD');
71
+      if(!$operator->password_verify($password)) {
72
+              throw new \Exception('ERR_WRONG_LOGIN_OR_PASSWORD');
73
+      }
70 74
 
71 75
       $this->box('StateAgent')->operator_id($operator->get_id());
72 76
       $this->logger()->nice(L('PAGE_CHECKIN_WELCOME', [$operator->name()]));
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace HexMakina\kadro\Controllers;
4 4
 
5
-use HexMakina\kadro\Auth\{Operator,Permission,ACL};
6
-use HexMakina\kadro\Auth\{OperatorInterface,AccessRefusedException};
5
+use HexMakina\kadro\Auth\{Operator, Permission, ACL};
6
+use HexMakina\kadro\Auth\{OperatorInterface, AccessRefusedException};
7 7
 
8 8
 class ReceptionController extends KadroController
9 9
 {
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
   public function welcome(OperatorInterface $operator)
16 16
   {
17 17
 
18
-    if($this->router()->name() === 'identify')
18
+    if ($this->router()->name() === 'identify')
19 19
       $this->identify($operator);
20 20
 
21 21
     $Controller = $this->router()->target_controller();
22 22
     $Controller = $this->box($Controller);
23 23
 
24 24
 
25
-    if($Controller->requires_operator())
25
+    if ($Controller->requires_operator())
26 26
     {
27
-      if(is_null($operator = get_class($operator)::exists($this->box('StateAgent')->operator_id())))
27
+      if (is_null($operator = get_class($operator)::exists($this->box('StateAgent')->operator_id())))
28 28
         $this->router()->hop('checkin');
29 29
 
30
-      if(!$operator->is_active())
30
+      if (!$operator->is_active())
31 31
       {
32 32
         $this->checkout();
33 33
         throw new AccessRefusedException();
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 
60 60
       $operator = get_class($op)::exists(['username' => $username]);
61 61
 
62
-      if(is_null($operator) || !$operator->is_active())
62
+      if (is_null($operator) || !$operator->is_active())
63 63
         throw new \Exception('ERR_DISABLED');
64 64
 
65
-      if(!$operator->password_verify($password))
65
+      if (!$operator->password_verify($password))
66 66
         throw new \Exception('ERR_WRONG_LOGIN_OR_PASSWORD');
67 67
 
68 68
       $this->box('StateAgent')->operator_id($operator->get_id());
Please login to merge, or discard this patch.