Skip to content

Commit 3416edc

Browse files
committed
Typo fixes and code cleanup
1 parent 80dfe20 commit 3416edc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/Formatter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Ayesh\PHP_Timer;
55

66
/**
7-
* Class Formmater
7+
* Class Formatter
88
* Formatter helper to format time intervals.
99
* @internal
1010
* @package Ayesh\PHP_Timer
@@ -14,7 +14,7 @@ class Formatter {
1414
private function __construct() {
1515
}
1616

17-
public static function formatTime(int $miliseconds): string {
17+
public static function formatTime(int $milliseconds): string {
1818
$units = [ // Do not reorder the array order.
1919
31536000000 => ['1 year', '@count years'],
2020
2592000000 => ['1 month', '@count months'],
@@ -29,9 +29,9 @@ public static function formatTime(int $miliseconds): string {
2929
$granularity = 2;
3030
$output = [];
3131
foreach ($units as $value => $string_pair) {
32-
if ($miliseconds >= $value) {
33-
$output[] = static::formatPlural((int) floor($miliseconds / $value), $string_pair[0], $string_pair[1]);
34-
$miliseconds %= $value;
32+
if ($milliseconds >= $value) {
33+
$output[] = static::formatPlural((int) floor($milliseconds / $value), $string_pair[0], $string_pair[1]);
34+
$milliseconds %= $value;
3535
$granularity--;
3636
}
3737
if ($granularity === 0) {

src/Timer.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Ayesh\PHP_Timer;
55

6+
use LogicException;
7+
use function round;
8+
69
/**
710
* Class Timer
811
*
@@ -84,7 +87,7 @@ public static function resetAll(): void {
8487
* formats.
8588
*
8689
* @return mixed The formatted time, formatted by the formatter string passed for $format.
87-
* @throws \LogicException
90+
* @throws LogicException
8891
* If the timer was not started, a \LogicException will be thrown. Use @see \Ayesh\PHP_Timer\Timer::start()
8992
* to start a timer.
9093
*/
@@ -93,7 +96,7 @@ public static function read(string $key = 'default', $format = self::FORMAT_MILL
9396
return self::formatTime(self::$timers[$key]->read(), $format);
9497
}
9598

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.');
97100
}
98101

99102
/**
@@ -122,7 +125,7 @@ private static function formatTime(float $value, $format): string {
122125
}
123126

124127
private static function secondsToTimeString(float $time): string {
125-
$ms = (int) \round($time * 1000);
128+
$ms = (int) round($time * 1000);
126129
return Formatter::formatTime($ms);
127130
}
128131

@@ -131,11 +134,11 @@ private static function secondsToTimeString(float $time): string {
131134
*
132135
* @param string $key
133136
*
134-
* @throws \LogicException If the attempted timer has not started already.
137+
* @throws LogicException If the attempted timer has not started already.
135138
*/
136139
public static function stop($key = 'default'): void {
137140
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.');
139142
}
140143

141144
self::$timers[$key]->stop();

0 commit comments

Comments
 (0)