-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * LeagueStatsDClientAdapter converts stats * DatadogStatsDClientAdapter converts stats * InMemoryClientAdapter converts stats * lines should not exceed 80 chars * remove one-line method and replace with static call * rename return value * add some tests * test for string * tests for enums * use common enums * clean up * DogStatsDSpy * confirm that DataDogStatsDClientAdapter converts enums and array of enums
- Loading branch information
1 parent
6c4d841
commit 71f8b89
Showing
24 changed files
with
777 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Cosmastech\StatsDClientAdapter\Adapters\Concerns; | ||
|
||
use Cosmastech\StatsDClientAdapter\Utility\EnumConverter; | ||
|
||
trait ConvertsStatTrait | ||
{ | ||
/** | ||
* @param mixed $value | ||
* @return string|array<int, string> | ||
* @phpstan-return ($value is array ? array<int, string> : string) | ||
*/ | ||
protected function convertStat(mixed $value): string|array | ||
{ | ||
if (is_array($value)) { | ||
$convertedStats = []; | ||
foreach($value as $element) { | ||
$convertedStats[] = $this->convertValueToString($element); | ||
} | ||
|
||
return $convertedStats; | ||
} | ||
|
||
return $this->convertValueToString($value); | ||
} | ||
|
||
protected function convertValueToString(mixed $value): string | ||
{ | ||
return (string) EnumConverter::convertIfEnum($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.