Loading src/Plugin/Tamper/FindReplace.php +2 −2 Original line number Diff line number Diff line Loading @@ -96,8 +96,8 @@ class FindReplace extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } $function = $this->getFunction(); Loading src/Plugin/Tamper/FindReplaceRegex.php +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ class FindReplaceRegex extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } $find = $this->getSetting(self::SETTING_FIND); $replace = $this->getSetting(self::SETTING_REPLACE); Loading src/Plugin/Tamper/Sprintf.php +2 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ class Sprintf extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } return sprintf($this->getSetting(self::SETTING_TEXT_FORMAT), $data); } Loading src/Plugin/Tamper/StrPad.php +2 −2 Original line number Diff line number Diff line Loading @@ -89,8 +89,8 @@ class StrPad extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } return str_pad($data, $this->getSetting(self::SETTING_PAD_LENGTH), $this->getSetting(self::SETTING_PAD_STRING), $this->getSetting(self::SETTING_PAD_TYPE)); Loading tests/src/Unit/Plugin/Tamper/FindReplaceRegexTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,20 @@ class FindReplaceRegexTest extends TamperPluginTestBase { $this->assertEquals('The dog went to the park.', $plugin->tamper('The Cat went to the park.')); } /** * Test the plugin with a single numeric value. */ public function testNumericValue() { $config = [ FindReplaceRegex::SETTING_FIND => '/5/', FindReplaceRegex::SETTING_REPLACE => '8', FindReplaceRegex::SETTING_LIMIT => '', ]; $plugin = new FindReplaceRegex($config, 'find_replace_regex', [], $this->getMockSourceDefinition()); $this->assertEquals('8', $plugin->tamper(5)); $this->assertEquals('7', $plugin->tamper(7)); } /** * Test the plugin as respecting word boundaries. */ Loading Loading
src/Plugin/Tamper/FindReplace.php +2 −2 Original line number Diff line number Diff line Loading @@ -96,8 +96,8 @@ class FindReplace extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } $function = $this->getFunction(); Loading
src/Plugin/Tamper/FindReplaceRegex.php +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ class FindReplaceRegex extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } $find = $this->getSetting(self::SETTING_FIND); $replace = $this->getSetting(self::SETTING_REPLACE); Loading
src/Plugin/Tamper/Sprintf.php +2 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ class Sprintf extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } return sprintf($this->getSetting(self::SETTING_TEXT_FORMAT), $data); } Loading
src/Plugin/Tamper/StrPad.php +2 −2 Original line number Diff line number Diff line Loading @@ -89,8 +89,8 @@ class StrPad extends TamperBase { * {@inheritdoc} */ public function tamper($data, TamperableItemInterface $item = NULL) { if (!is_string($data)) { throw new TamperException('Input should be a string.'); if (!is_string($data) && !is_numeric($data)) { throw new TamperException('Input should be a string or numeric.'); } return str_pad($data, $this->getSetting(self::SETTING_PAD_LENGTH), $this->getSetting(self::SETTING_PAD_STRING), $this->getSetting(self::SETTING_PAD_TYPE)); Loading
tests/src/Unit/Plugin/Tamper/FindReplaceRegexTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,20 @@ class FindReplaceRegexTest extends TamperPluginTestBase { $this->assertEquals('The dog went to the park.', $plugin->tamper('The Cat went to the park.')); } /** * Test the plugin with a single numeric value. */ public function testNumericValue() { $config = [ FindReplaceRegex::SETTING_FIND => '/5/', FindReplaceRegex::SETTING_REPLACE => '8', FindReplaceRegex::SETTING_LIMIT => '', ]; $plugin = new FindReplaceRegex($config, 'find_replace_regex', [], $this->getMockSourceDefinition()); $this->assertEquals('8', $plugin->tamper(5)); $this->assertEquals('7', $plugin->tamper(7)); } /** * Test the plugin as respecting word boundaries. */ Loading