3
3
4
4
namespace Ayesh \PHP_Timer ;
5
5
6
+ use LogicException ;
7
+ use function round ;
8
+
6
9
/**
7
10
* Class Timer
8
11
*
@@ -84,7 +87,7 @@ public static function resetAll(): void {
84
87
* formats.
85
88
*
86
89
* @return mixed The formatted time, formatted by the formatter string passed for $format.
87
- * @throws \ LogicException
90
+ * @throws LogicException
88
91
* If the timer was not started, a \LogicException will be thrown. Use @see \Ayesh\PHP_Timer\Timer::start()
89
92
* to start a timer.
90
93
*/
@@ -93,7 +96,7 @@ public static function read(string $key = 'default', $format = self::FORMAT_MILL
93
96
return self ::formatTime (self ::$ timers [$ key ]->read (), $ format );
94
97
}
95
98
96
- throw new \ LogicException ('Reading timer when the given key timer was not initialized. ' );
99
+ throw new LogicException ('Reading timer when the given key timer was not initialized. ' );
97
100
}
98
101
99
102
/**
@@ -122,7 +125,7 @@ private static function formatTime(float $value, $format): string {
122
125
}
123
126
124
127
private static function secondsToTimeString (float $ time ): string {
125
- $ ms = (int ) \ round ($ time * 1000 );
128
+ $ ms = (int ) round ($ time * 1000 );
126
129
return Formatter::formatTime ($ ms );
127
130
}
128
131
@@ -131,11 +134,11 @@ private static function secondsToTimeString(float $time): string {
131
134
*
132
135
* @param string $key
133
136
*
134
- * @throws \ LogicException If the attempted timer has not started already.
137
+ * @throws LogicException If the attempted timer has not started already.
135
138
*/
136
139
public static function stop ($ key = 'default ' ): void {
137
140
if (!isset (self ::$ timers [$ key ])) {
138
- throw new \ LogicException ('Stopping timer when the given key timer was not initialized. ' );
141
+ throw new LogicException ('Stopping timer when the given key timer was not initialized. ' );
139
142
}
140
143
141
144
self ::$ timers [$ key ]->stop ();
0 commit comments