-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Neveldo\TextGenerator\TextFunction; | ||
|
||
use Neveldo\TextGenerator\Tag\TagReplacerInterface; | ||
|
||
/** | ||
* Class c | ||
* 'rmna' function : return the argument only if it does not contain any empty values | ||
* Examples : | ||
* #rmna{one @possible_not_available_tag two} | ||
* | ||
* @package Neveldo\TextGenerator\TextFunction | ||
*/ | ||
class RmnaFunction implements FunctionInterface | ||
{ | ||
/** | ||
* @var TagReplacerInterface Tag Replacer service | ||
*/ | ||
private $tagReplacer; | ||
|
||
/** | ||
* RandomFunction constructor. | ||
* @param TagReplacerInterface $tagReplacer | ||
*/ | ||
public function __construct(TagReplacerInterface $tagReplacer) | ||
{ | ||
$this->tagReplacer = $tagReplacer; | ||
} | ||
|
||
/** | ||
* Handle rmna function | ||
* @param array $arguments list of arguments where tags have been replaced by their values | ||
* @param array $originalArguments list of original arguments | ||
*/ | ||
public function execute(array $arguments, array $originalArguments) | ||
{ | ||
if (count($arguments) === 0 | ||
|| mb_strpos($arguments[0], $this->tagReplacer->getEmptyTag()) !== false | ||
) { | ||
return ''; | ||
} | ||
|
||
return $arguments[0]; | ||
} | ||
|
||
} |
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