Completed
Push — master ( 7e3160...7dabfe )
by Chris
04:01
created
php/hamle/Scope.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
       self::$namedScopes[$name]->rewind();
68 68
       return self::$namedScopes[$name];
69 69
     } else
70
-      if(self::$returnZeroOnNoScope)
70
+      if (self::$returnZeroOnNoScope)
71 71
         return new Model\Zero();
72 72
       throw new RunTime("Unable to find scope ($name)");
73 73
   }
Please login to merge, or discard this patch.
Braces   +23 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,12 +18,14 @@  discard block
 block discarded – undo
18 18
   static $namedScopes = array();
19 19
 
20 20
   static function add($model, $name = null) {
21
-    if (!$model instanceOf Model)
22
-      throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
23
-    if ($name)
24
-      self::$namedScopes[$name] = $model;
25
-    else
26
-      self::$scopes[] = $model;
21
+    if (!$model instanceOf Model) {
22
+          throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
23
+    }
24
+    if ($name) {
25
+          self::$namedScopes[$name] = $model;
26
+    } else {
27
+          self::$scopes[] = $model;
28
+    }
27 29
   }
28 30
 
29 31
   static function done() {
@@ -41,15 +43,21 @@  discard block
 block discarded – undo
41 43
    */
42 44
   static function get($id = 0) {
43 45
     if (0 == $id) {
44
-      if ($scope = end(self::$scopes))
45
-        return $scope;
46
+      if ($scope = end(self::$scopes)) {
47
+              return $scope;
48
+      }
46 49
       throw new OutOfScope("Unable to find Scope ($id)");
47 50
     }
48 51
     $key = $id - 1;
49
-    if ($id < 0) $key = count(self::$scopes) + $id - 1;
50
-    if ($id == 0) $key = count(self::$scopes) - 1;
51
-    if (!isset(self::$scopes[$key]))
52
-      throw new OutOfScope("Unable to find Scope ($id) or $key");
52
+    if ($id < 0) {
53
+      $key = count(self::$scopes) + $id - 1;
54
+    }
55
+    if ($id == 0) {
56
+      $key = count(self::$scopes) - 1;
57
+    }
58
+    if (!isset(self::$scopes[$key])) {
59
+          throw new OutOfScope("Unable to find Scope ($id) or $key");
60
+    }
53 61
     return self::$scopes[$key];
54 62
   }
55 63
 
@@ -67,8 +75,9 @@  discard block
 block discarded – undo
67 75
       self::$namedScopes[$name]->rewind();
68 76
       return self::$namedScopes[$name];
69 77
     } else
70
-      if(self::$returnZeroOnNoScope)
71
-        return new Model\Zero();
78
+      if(self::$returnZeroOnNoScope) {
79
+              return new Model\Zero();
80
+      }
72 81
       throw new RunTime("Unable to find scope ($name)");
73 82
   }
74 83
 
Please login to merge, or discard this patch.