@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class ConvertHelper_TimeConverter |
25 | 25 | { |
26 | - /** |
|
27 | - * @var float |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var float |
|
28 | + */ |
|
29 | 29 | private $seconds; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array<int,array<string,string|int>> |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array<int,array<string,string|int>> |
|
33 | + */ |
|
34 | 34 | private static $units; |
35 | 35 | |
36 | - /** |
|
37 | - * @param float $seconds |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @param float $seconds |
|
38 | + */ |
|
39 | 39 | public function __construct($seconds) |
40 | 40 | { |
41 | 41 | $this->seconds = $seconds; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $this->initUnits(); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Creates the list of units once per request as needed. |
|
48 | - */ |
|
46 | + /** |
|
47 | + * Creates the list of units once per request as needed. |
|
48 | + */ |
|
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | 51 | if(isset(self::$units)) |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Resolves the list of converted units. |
|
117 | - * |
|
118 | - * @return string[] |
|
119 | - */ |
|
115 | + /** |
|
116 | + * Resolves the list of converted units. |
|
117 | + * |
|
118 | + * @return string[] |
|
119 | + */ |
|
120 | 120 | private function resolveTokens() : array |
121 | 121 | { |
122 | 122 | $seconds = $this->seconds; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | - if(isset(self::$units)) |
|
51 | + if (isset(self::$units)) |
|
52 | 52 | { |
53 | 53 | return; |
54 | 54 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | public function toString() : string |
91 | 91 | { |
92 | 92 | // specifically handle zero |
93 | - if($this->seconds <= 0) |
|
93 | + if ($this->seconds <= 0) |
|
94 | 94 | { |
95 | - return '0 ' . t('seconds'); |
|
95 | + return '0 '.t('seconds'); |
|
96 | 96 | } |
97 | 97 | |
98 | - if($this->seconds < 1) |
|
98 | + if ($this->seconds < 1) |
|
99 | 99 | { |
100 | 100 | return t('less than a second'); |
101 | 101 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | |
105 | 105 | $last = array_pop($tokens); |
106 | 106 | |
107 | - if(empty($tokens)) |
|
107 | + if (empty($tokens)) |
|
108 | 108 | { |
109 | 109 | return $last; |
110 | 110 | } |
111 | 111 | |
112 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
112 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | $seconds = $this->seconds; |
123 | 123 | $tokens = array(); |
124 | 124 | |
125 | - foreach(self::$units as $def) |
|
125 | + foreach (self::$units as $def) |
|
126 | 126 | { |
127 | 127 | $unitValue = intval($seconds / $def['value']); |
128 | 128 | |
129 | - if($unitValue <= 0) |
|
129 | + if ($unitValue <= 0) |
|
130 | 130 | { |
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | - $item = strval($unitValue) . ' '; |
|
134 | + $item = strval($unitValue).' '; |
|
135 | 135 | |
136 | - if(abs($unitValue) > 1) |
|
136 | + if (abs($unitValue) > 1) |
|
137 | 137 | { |
138 | 138 | $item .= $def['plural']; |
139 | 139 | } |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if(abs($unitValue) > 1) |
137 | 137 | { |
138 | 138 | $item .= $def['plural']; |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | $item .= $def['singular']; |
143 | 142 | } |