Last active
October 4, 2019 14:45
-
-
Save zavodnoyapl1992/ed9a13d2c1439778edcdc050e4398c6a to your computer and use it in GitHub Desktop.
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
<?php | |
class Trans { | |
private $word; | |
public function __construct(string $word) { | |
$this->word = $word; | |
} | |
public function __invoke(array $replaces) { | |
return str_replace(array_keys($replaces), array_values($replaces), $this->word); | |
} | |
public function __toString() { | |
return $this->word; | |
} | |
} | |
$a = new Trans('Hello World'); | |
echo $a; | |
echo $a(['Hello' => 'Buy']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment