Completed
Push — master ( 1f9686...114e61 )
by Stefano
03:01
created
classes/Module.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 trait Module {
14 14
     static protected $__PROTOTYPE = array();
15 15
 
16
-    final public function __call($name, $args){
16
+    final public function __call($name, $args) {
17 17
       if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure)
18 18
         return call_user_func_array(static::$__PROTOTYPE[$name]->bindTo($this, $this), $args);
19 19
       if (get_parent_class())
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
       else throw new \BadMethodCallException;
22 22
     }
23 23
 
24
-    final public static function __callStatic($name, $args){
24
+    final public static function __callStatic($name, $args) {
25 25
       if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure)
26 26
         return forward_static_call_array(static::$__PROTOTYPE[$name], $args);
27 27
       if (get_parent_class()) return parent::__callStatic($name, $args);
28 28
       else throw new \BadMethodCallException;
29 29
     }
30 30
 
31
-    public static function extend($methods = []){
31
+    public static function extend($methods = []) {
32 32
       if ($methods) foreach ($methods as $name => $method) {
33 33
         if ($method && $method instanceof \Closure)
34 34
           static::$__PROTOTYPE[$name] = $method;
Please login to merge, or discard this patch.
Braces   +24 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,26 +13,36 @@
 block discarded – undo
13 13
 trait Module {
14 14
     static protected $__PROTOTYPE = array();
15 15
 
16
-    final public function __call($name, $args){
17
-      if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure)
18
-        return call_user_func_array(static::$__PROTOTYPE[$name]->bindTo($this, $this), $args);
19
-      if (get_parent_class())
20
-        return parent::__call($name, $args);
21
-      else throw new \BadMethodCallException;
16
+    final public function __call($name, $args) {
17
+      if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure) {
18
+              return call_user_func_array(static::$__PROTOTYPE[$name]->bindTo($this, $this), $args);
19
+      }
20
+      if (get_parent_class()) {
21
+              return parent::__call($name, $args);
22
+      } else {
23
+        throw new \BadMethodCallException;
24
+      }
22 25
     }
23 26
 
24
-    final public static function __callStatic($name, $args){
25
-      if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure)
26
-        return forward_static_call_array(static::$__PROTOTYPE[$name], $args);
27
-      if (get_parent_class()) return parent::__callStatic($name, $args);
28
-      else throw new \BadMethodCallException;
27
+    final public static function __callStatic($name, $args) {
28
+      if (isset(static::$__PROTOTYPE[$name]) && static::$__PROTOTYPE[$name] instanceof \Closure) {
29
+              return forward_static_call_array(static::$__PROTOTYPE[$name], $args);
30
+      }
31
+      if (get_parent_class()) {
32
+        return parent::__callStatic($name, $args);
33
+      } else {
34
+        throw new \BadMethodCallException;
35
+      }
29 36
     }
30 37
 
31
-    public static function extend($methods = []){
32
-      if ($methods) foreach ($methods as $name => $method) {
38
+    public static function extend($methods = []) {
39
+      if ($methods) {
40
+        foreach ($methods as $name => $method) {
33 41
         if ($method && $method instanceof \Closure)
34 42
           static::$__PROTOTYPE[$name] = $method;
35
-        else throw new \BadMethodCallException;
43
+      } else {
44
+          throw new \BadMethodCallException;
45
+        }
36 46
       }
37 47
     }
38 48
 
Please login to merge, or discard this patch.
classes/Model.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     public static function create($data){
43 43
       $tmp = new static;
44 44
       foreach ((array)$data as $key => $value) {
45
-         $tmp->$key = $value;
45
+          $tmp->$key = $value;
46 46
       }
47 47
       $tmp->save();
48 48
       return $tmp;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 abstract class Model {
14 14
     use Module, Persistence;
15 15
 
16
-    public static function where($where_sql = false){
16
+    public static function where($where_sql = false) {
17 17
       // Forward persistence calls to caller class, not Model
18 18
       $self  = get_called_class();
19 19
       $table = $self::persistenceOptions('table');
20 20
       $key   = $self::persistenceOptions('key');
21 21
 
22
-      $sql   = "select $key from $table" . ($where_sql ? " where $where_sql" : '');
22
+      $sql   = "select $key from $table".($where_sql ? " where $where_sql" : '');
23 23
 
24 24
       $results = [];
25 25
       SQL::each($sql, function($row) use ($self, &$results, $key){
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
       return $results;
29 29
     }
30 30
 
31
-    public static function all($page=1, $limit=-1){
32
-      $offset = max(1,$page)-1;
31
+    public static function all($page = 1, $limit = -1) {
32
+      $offset = max(1, $page) - 1;
33 33
       return static::where($limit < 1 ? "" : "1 limit $limit offset $offset");
34 34
     }
35 35
 
36
-    public function primaryKey(){
36
+    public function primaryKey() {
37 37
       $self = get_called_class();
38 38
       $key  = $self::persistenceOptions('key');
39 39
       return $this->$key;
40 40
     }
41 41
 
42
-    public static function create($data){
42
+    public static function create($data) {
43 43
       $tmp = new static;
44
-      foreach ((array)$data as $key => $value) {
44
+      foreach ((array) $data as $key => $value) {
45 45
          $tmp->$key = $value;
46 46
       }
47 47
       $tmp->save();
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 abstract class Model {
14 14
     use Module, Persistence;
15 15
 
16
-    public static function where($where_sql = false){
16
+    public static function where($where_sql = false) {
17 17
       // Forward persistence calls to caller class, not Model
18 18
       $self  = get_called_class();
19 19
       $table = $self::persistenceOptions('table');
@@ -22,24 +22,24 @@  discard block
 block discarded – undo
22 22
       $sql   = "select $key from $table" . ($where_sql ? " where $where_sql" : '');
23 23
 
24 24
       $results = [];
25
-      SQL::each($sql, function($row) use ($self, &$results, $key){
25
+      SQL::each($sql, function($row) use ($self, &$results, $key) {
26 26
           $results[] = $self::load($row->$key);
27 27
       });
28 28
       return $results;
29 29
     }
30 30
 
31
-    public static function all($page=1, $limit=-1){
31
+    public static function all($page=1, $limit=-1) {
32 32
       $offset = max(1,$page)-1;
33 33
       return static::where($limit < 1 ? "" : "1 limit $limit offset $offset");
34 34
     }
35 35
 
36
-    public function primaryKey(){
36
+    public function primaryKey() {
37 37
       $self = get_called_class();
38 38
       $key  = $self::persistenceOptions('key');
39 39
       return $this->$key;
40 40
     }
41 41
 
42
-    public static function create($data){
42
+    public static function create($data) {
43 43
       $tmp = new static;
44 44
       foreach ((array)$data as $key => $value) {
45 45
          $tmp->$key = $value;
Please login to merge, or discard this patch.