Exemple #1
0
 /**
  * Replace if hit.
  * @param $row array Row in table.
  * @param $target string Replace target string.
  * @param $replace string Replace string.
  * @return boolean
  */
 private function replaceIfHit(&$row, $target, $replace)
 {
     $replaced = false;
     foreach ($row as &$column) {
         if (Replacer::execute($column, $target, $replace) && !$replaced) {
             $replaced = true;
         }
     }
     return $replaced;
 }
Exemple #2
0
 public function testExecute()
 {
     // string
     $stringObject = 'wwwcoinwww';
     $stringObjectRet = Replacer::execute($stringObject, 'coin', 'steak');
     $this->assertEquals($stringObjectRet, true);
     $this->assertEquals($stringObject, 'wwwsteakwww');
     // serialize string
     $serializeObject = 'a:2:{s:7:"company";s:7:"hikouki";s:7:"website";s:26:"https://github.com/hikouki";}';
     $serializeObjectRet = Replacer::execute($serializeObject, 'github.com', 'qiita.com');
     $this->assertEquals($serializeObjectRet, true);
     $this->assertEquals($serializeObject, Ser::maybe(['company' => 'hikouki', 'website' => 'https://qiita.com/hikouki']));
 }