Last active
June 3, 2022 18:37
-
-
Save vudaltsov/9cf6c68f418a3e4b440f853e3a0c0153 to your computer and use it in GitHub Desktop.
PHP Interpolator
This file contains hidden or 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
<?php | |
declare(strict_types=1); | |
final class Interpolator | |
{ | |
public function __construct( | |
private string $format = '%s', | |
) { | |
} | |
public function __invoke(mixed $value): string | |
{ | |
return sprintf($this->format, $value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment