Passed
Push — master ( 92cf14...693d98 )
by Richard
01:52
created
maphper/lib/dateinjector.php 1 patch
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,25 +6,35 @@
 block discarded – undo
6 6
 
7 7
 	public function replaceDates($obj, $reset = true) {
8 8
 		//prevent infinite recursion, only process each object once
9
-		if ($this->checkCache($obj, $reset)) return $obj;
9
+		if ($this->checkCache($obj, $reset)) {
10
+			return $obj;
11
+		}
10 12
 
11
-		if (is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator))) foreach ($obj as &$o) $o = $this->replaceDates($o, false);
13
+		if (is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator))) {
14
+			foreach ($obj as &$o) $o = $this->replaceDates($o, false);
15
+		}
12 16
 		if (is_string($obj) && isset($obj[0]) && is_numeric($obj[0]) && strlen($obj) <= 20) {
13 17
 			try {
14 18
 				$date = new \DateTime($obj);
15
-				if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) $obj = $date;
16
-			}
17
-			catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
19
+				if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) {
20
+					$obj = $date;
21
+				}
22
+			} catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
18 23
 			}
19 24
 		}
20 25
 		return $obj;
21 26
 	}
22 27
 
23 28
 	private function checkCache($obj, $reset) {
24
-		if ($reset) $this->processCache = new \SplObjectStorage();
29
+		if ($reset) {
30
+			$this->processCache = new \SplObjectStorage();
31
+		}
25 32
 
26
-		if (is_object($obj) && $this->processCache->contains($obj)) return $obj;
27
-		else if (is_object($obj)) $this->processCache->attach($obj, true);
33
+		if (is_object($obj) && $this->processCache->contains($obj)) {
34
+			return $obj;
35
+		} else if (is_object($obj)) {
36
+			$this->processCache->attach($obj, true);
37
+		}
28 38
 
29 39
 		return false;
30 40
 	}
Please login to merge, or discard this patch.