-
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.
Functions may use ' or " as params. Add functions: plural and printf.…
… Tested.
- Loading branch information
Showing
5 changed files
with
86 additions
and
2 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,26 @@ | ||
<?php | ||
/** | ||
* | ||
* PHP version >= 5.6 | ||
* | ||
* @package andydune/string-replace | ||
* @link https://github.com/AndyDune/StringReplace for the canonical source repository | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @author Andrey Ryzhov <info@rznw.ru> | ||
* @copyright 2018 Andrey Ryzhov | ||
*/ | ||
|
||
|
||
namespace AndyDune\StringReplace\Functions; | ||
|
||
|
||
class PluralStringEnglish | ||
{ | ||
public function __invoke($string, $form1 = '', $form2 = '') | ||
{ | ||
$n = (int)$string; | ||
if ($n == 1) return $form1; | ||
return $form2; | ||
} | ||
|
||
} |
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,28 @@ | ||
<?php | ||
/** | ||
* | ||
* PHP version >= 5.6 | ||
* | ||
* @package andydune/string-replace | ||
* @link https://github.com/AndyDune/StringReplace for the canonical source repository | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @author Andrey Ryzhov <info@rznw.ru> | ||
* @copyright 2018 Andrey Ryzhov | ||
*/ | ||
|
||
|
||
namespace AndyDune\StringReplace\Functions; | ||
|
||
|
||
class PrintFormatted | ||
{ | ||
public function __invoke($string, $format = '') | ||
{ | ||
$string = trim($string); | ||
if ($string) { | ||
return sprintf($format, $string); | ||
} | ||
return ''; | ||
} | ||
|
||
} |
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
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