Skip to content

Commit

Permalink
change order of time() params
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Jul 10, 2024
1 parent 23291c7 commit fa87890
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Adapters/Concerns/TimeClosureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait TimeClosureTrait
/**
* @inheritDoc
*/
public function time(string $stat, callable $closure, float $sampleRate = 1.0, array $tags = [])
public function time(callable $closure, string $stat, float $sampleRate = 1.0, array $tags = [])
{
$startTime = intval($this->clock->now()->format("Uv"));

Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/StatsDClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public function timing(string $stat, float $durationMs, float $sampleRate = 1.0,
/**
* Record a timing stat for the duration of the $closure.
*
* @param string $stat
* @param callable $closure
* @param string $stat
* @param float $sampleRate
* @param array<mixed, mixed> $tags
* @return mixed The return value of $closure
*/
public function time(string $stat, callable $closure, float $sampleRate = 1.0, array $tags = []);
public function time(callable $closure, string $stat, float $sampleRate = 1.0, array $tags = []);

/**
* @param string $stat
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapters/InMemory/InMemoryTimingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function time_storesDurationOfClosure(): void
$closure = fn () => "abc";

// When
$actualReturn = $inMemoryClient->time("my-stat", $closure);
$actualReturn = $inMemoryClient->time($closure, "my-stat");

// Then
self::assertEquals("abc", $actualReturn);
Expand Down

0 comments on commit fa87890

Please sign in to comment.