Passed
Push — master ( 92ec28...d3869d )
by Filippo
02:01
created
src/ToolBag/Helper/TimeHelper.php 1 patch
Braces   +27 added lines, -23 removed lines patch added patch discarded remove patch
@@ -69,8 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
       // Converts microseconds in seconds.
71 71
       $seconds = floor($microseconds / $microsecondsInASecond);
72
-    }
73
-    else {
72
+    } else {
74 73
       // Calculates difference in seconds.
75 74
       $seconds = time() - $timestamp;
76 75
     }
@@ -125,25 +124,29 @@  discard block
 block discarded – undo
125 124
     if ($today == date('Ymd', $timestamp)) {
126 125
       $time = self::since($timestamp);
127 126
 
128
-      if ($time['hours'] > 1)
129
-        return sprintf('%d hours ago', $time['hours']);
130
-      elseif ($time['hours'] == 1)
131
-        return "one hour ago";
132
-      elseif ($time['minutes'] > 1)
133
-        return sprintf('%d minutes ago', $time['minutes']);
134
-      elseif ($time['minutes'] == 1)
135
-        return "one minute ago";
136
-      elseif ($time['seconds'] > 1)
137
-        return sprintf('%d seconds ago', $time['seconds']);
138
-      else // $time['seconds'] == 1
127
+      if ($time['hours'] > 1) {
128
+              return sprintf('%d hours ago', $time['hours']);
129
+      } elseif ($time['hours'] == 1) {
130
+              return "one hour ago";
131
+      } elseif ($time['minutes'] > 1) {
132
+              return sprintf('%d minutes ago', $time['minutes']);
133
+      } elseif ($time['minutes'] == 1) {
134
+              return "one minute ago";
135
+      } elseif ($time['seconds'] > 1) {
136
+              return sprintf('%d seconds ago', $time['seconds']);
137
+      } else {
138
+        // $time['seconds'] == 1
139 139
         return "one second ago";
140
+      }
140 141
     }
141 142
     // Yesterday.
142
-    elseif (strtotime('-1 day', $today) == date('Ymd', $timestamp))
143
-      return "yesterday";
143
+    elseif (strtotime('-1 day', $today) == date('Ymd', $timestamp)) {
144
+          return "yesterday";
145
+    }
144 146
     // In the past.
145
-    else
146
-      return $showTime ? date('d/m/Y H:i', $timestamp) : date('d/m/Y', $timestamp);
147
+    else {
148
+          return $showTime ? date('d/m/Y H:i', $timestamp) : date('d/m/Y', $timestamp);
149
+    }
147 150
   }
148 151
 
149 152
 
@@ -257,12 +260,13 @@  discard block
 block discarded – undo
257 260
     $minDate = (new \DateTime())->setDate($aYear, $aMonth, $aDay)->modify('midnight');
258 261
     $maxDate = clone($minDate);
259 262
 
260
-    if (isset($day))
261
-      $maxDate->modify('tomorrow')->modify('last second');
262
-    elseif (isset($month))
263
-      $maxDate->modify('last day of this month')->modify('last second');
264
-    else
265
-      $maxDate->setDate($aYear, 12, 31)->modify('last second');
263
+    if (isset($day)) {
264
+          $maxDate->modify('tomorrow')->modify('last second');
265
+    } elseif (isset($month)) {
266
+          $maxDate->modify('last day of this month')->modify('last second');
267
+    } else {
268
+          $maxDate->setDate($aYear, 12, 31)->modify('last second');
269
+    }
266 270
   }
267 271
 
268 272
 }
269 273
\ No newline at end of file
Please login to merge, or discard this patch.