Completed
Push — master ( 1f8425...5030da )
by mehdi
02:52
created
src/TimeAgo.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -8,6 +8,9 @@
 block discarded – undo
8 8
 
9 9
   private $language;
10 10
 
11
+  /**
12
+   * @param string $lang
13
+   */
11 14
   public function __construct( $timestamp, $lang ) {
12 15
 
13 16
     $this->language = $lang;
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,105 +8,105 @@
 block discarded – undo
8 8
 
9 9
   private $language;
10 10
 
11
-  public function __construct( $timestamp, $lang ) {
11
+  public function __construct($timestamp, $lang) {
12 12
 
13 13
     $this->language = $lang;
14 14
 
15 15
     $time_ago = strtotime($timestamp->format('Y-m-d H:i:s'));
16 16
 
17
-    $cur_time   = time();
17
+    $cur_time = time();
18 18
 
19
-    $time_elapsed   = $cur_time - strtotime($timestamp->format('Y-m-d H:i:s'));
19
+    $time_elapsed = $cur_time - strtotime($timestamp->format('Y-m-d H:i:s'));
20 20
 
21
-    $this->second    = $time_elapsed ;
21
+    $this->second    = $time_elapsed;
22 22
 
23
-    $this->minute    = round($time_elapsed / 60 );
23
+    $this->minute    = round($time_elapsed / 60);
24 24
 
25
-    $this->quarter = round($time_elapsed / 900 );
25
+    $this->quarter = round($time_elapsed / 900);
26 26
 
27
-    $this->half = round($time_elapsed / 1800 );
27
+    $this->half = round($time_elapsed / 1800);
28 28
 
29
-    $this->hour     = round($time_elapsed / 3600);
29
+    $this->hour = round($time_elapsed / 3600);
30 30
 
31
-    $this->day     = round($time_elapsed / 86400 );
31
+    $this->day = round($time_elapsed / 86400);
32 32
 
33
-    $this->week     = round($time_elapsed / 604800);
33
+    $this->week = round($time_elapsed / 604800);
34 34
 
35
-    $this->month     = round($time_elapsed / 2600640 );
35
+    $this->month = round($time_elapsed / 2600640);
36 36
 
37
-    $this->year     = round($time_elapsed / 31207680 );
37
+    $this->year = round($time_elapsed / 31207680);
38 38
 
39 39
   }
40 40
 
41 41
   public function get() {
42 42
 
43 43
     // Seconds
44
-    if($this->second <= 60) {
45
-        return Lang::get($this->language, "just-now" );
44
+    if ($this->second <= 60) {
45
+        return Lang::get($this->language, "just-now");
46 46
     }
47 47
     //Minutes
48
-    else if($this->minute <=60){
49
-        if($this->minute==1){
50
-            return Lang::get($this->language, 'one-minute') . " " .
48
+    else if ($this->minute <= 60) {
49
+        if ($this->minute == 1) {
50
+            return Lang::get($this->language, 'one-minute')." ".
51 51
               Lang::get($this->language, 'ago');
52 52
         }
53
-        else{
54
-            return "$this->minute " . Lang::get($this->language, 'minutes')
55
-              . " " .
53
+        else {
54
+            return "$this->minute ".Lang::get($this->language, 'minutes')
55
+              . " ".
56 56
               Lang::get($this->language, 'ago');
57 57
         }
58 58
     }
59 59
     //Hours
60
-    else if($this->hour <=24){
61
-        if($this->hour==1){
62
-          return Lang::get($this->language, 'an-hour') . " " .
60
+    else if ($this->hour <= 24) {
61
+        if ($this->hour == 1) {
62
+          return Lang::get($this->language, 'an-hour')." ".
63 63
             Lang::get($this->language, 'ago');
64
-        }else{
65
-          return "$this->hour " . Lang::get($this->language, 'hours')
66
-            . " " .
64
+        } else {
65
+          return "$this->hour ".Lang::get($this->language, 'hours')
66
+            . " ".
67 67
             Lang::get($this->language, 'ago');
68 68
         }
69 69
     }
70 70
     //Days
71
-    else if($this->day <= 7){
72
-        if($this->day==1){
71
+    else if ($this->day <= 7) {
72
+        if ($this->day == 1) {
73 73
           return Lang::get($this->language, 'yesterday');
74
-        }else{
75
-          return "$this->day " . Lang::get($this->language, 'days')
76
-            . " " .
74
+        } else {
75
+          return "$this->day ".Lang::get($this->language, 'days')
76
+            . " ".
77 77
             Lang::get($this->language, 'ago');
78 78
         }
79 79
     }
80 80
     //Weeks
81
-    else if($this->week <= 4.3){
82
-        if($this->week==1){
83
-          return Lang::get($this->language, 'a-week') . " " .
81
+    else if ($this->week <= 4.3) {
82
+        if ($this->week == 1) {
83
+          return Lang::get($this->language, 'a-week')." ".
84 84
             Lang::get($this->language, 'ago');
85
-        }else{
86
-          return "$this->week " . Lang::get($this->language, 'weeks')
87
-            . " " .
85
+        } else {
86
+          return "$this->week ".Lang::get($this->language, 'weeks')
87
+            . " ".
88 88
             Lang::get($this->language, 'ago');
89 89
         }
90 90
     }
91 91
     //Months
92
-    else if($this->month <=12){
93
-        if($this->month==1){
94
-          return Lang::get($this->language, 'a-month') . " " .
92
+    else if ($this->month <= 12) {
93
+        if ($this->month == 1) {
94
+          return Lang::get($this->language, 'a-month')." ".
95 95
             Lang::get($this->language, 'ago');
96
-        }else{
97
-          return "$this->month " . Lang::get($this->language, 'months')
98
-            . " " .
96
+        } else {
97
+          return "$this->month ".Lang::get($this->language, 'months')
98
+            . " ".
99 99
             Lang::get($this->language, 'ago');
100 100
         }
101 101
     }
102 102
     //Years
103
-    else{
104
-        if($this->year==1){
105
-          return Lang::get($this->language, 'one-year') . " " .
103
+    else {
104
+        if ($this->year == 1) {
105
+          return Lang::get($this->language, 'one-year')." ".
106 106
             Lang::get($this->language, 'ago');
107
-        }else{
108
-          return "$this->year " . Lang::get($this->language, 'years')
109
-            . " " .
107
+        } else {
108
+          return "$this->year ".Lang::get($this->language, 'years')
109
+            . " ".
110 110
             Lang::get($this->language, 'ago');
111 111
         }
112 112
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
         if($this->minute==1){
50 50
             return Lang::get($this->language, 'one-minute') . " " .
51 51
               Lang::get($this->language, 'ago');
52
-        }
53
-        else{
52
+        } else{
54 53
             return "$this->minute " . Lang::get($this->language, 'minutes')
55 54
               . " " .
56 55
               Lang::get($this->language, 'ago');
@@ -61,7 +60,7 @@  discard block
 block discarded – undo
61 60
         if($this->hour==1){
62 61
           return Lang::get($this->language, 'an-hour') . " " .
63 62
             Lang::get($this->language, 'ago');
64
-        }else{
63
+        } else{
65 64
           return "$this->hour " . Lang::get($this->language, 'hours')
66 65
             . " " .
67 66
             Lang::get($this->language, 'ago');
@@ -71,7 +70,7 @@  discard block
 block discarded – undo
71 70
     else if($this->day <= 7){
72 71
         if($this->day==1){
73 72
           return Lang::get($this->language, 'yesterday');
74
-        }else{
73
+        } else{
75 74
           return "$this->day " . Lang::get($this->language, 'days')
76 75
             . " " .
77 76
             Lang::get($this->language, 'ago');
@@ -82,7 +81,7 @@  discard block
 block discarded – undo
82 81
         if($this->week==1){
83 82
           return Lang::get($this->language, 'a-week') . " " .
84 83
             Lang::get($this->language, 'ago');
85
-        }else{
84
+        } else{
86 85
           return "$this->week " . Lang::get($this->language, 'weeks')
87 86
             . " " .
88 87
             Lang::get($this->language, 'ago');
@@ -93,7 +92,7 @@  discard block
 block discarded – undo
93 92
         if($this->month==1){
94 93
           return Lang::get($this->language, 'a-month') . " " .
95 94
             Lang::get($this->language, 'ago');
96
-        }else{
95
+        } else{
97 96
           return "$this->month " . Lang::get($this->language, 'months')
98 97
             . " " .
99 98
             Lang::get($this->language, 'ago');
@@ -104,7 +103,7 @@  discard block
 block discarded – undo
104 103
         if($this->year==1){
105 104
           return Lang::get($this->language, 'one-year') . " " .
106 105
             Lang::get($this->language, 'ago');
107
-        }else{
106
+        } else{
108 107
           return "$this->year " . Lang::get($this->language, 'years')
109 108
             . " " .
110 109
             Lang::get($this->language, 'ago');
Please login to merge, or discard this patch.