I have class with some basic string operations. Any suggestion to improve the class
class StringHelpers
{
function replace_between($str, $needle_start, $needle_end, $replacement) {
$pos = strpos($str, $needle_start);
$start = $pos === false ? 0 : $pos + strlen($needle_start);
$pos = strpos($str, $needle_end, $start);
$end = $start === false ? strlen($str) : $pos;
return substr_replace($str,$replacement, $start, $end - $start);
}
function getTextBetweenTags($string, $tagname) {
$pattern = "/<$tagname>([\w\W]*?)<\/$tagname>/";
preg_match($pattern, $string, $matches);
return $matches[1];
}
function checkIfValueContainLetters($value){
return preg_match('/[A-Z]+[a-z]+[0-9]+/', $value);
}
public function createTableRowElementsByValue($bgColor, $tdName, $tdValue)
{
$tableRow = '<tr bgcolor="' . $bgColor . '"><td>' . $tdName . '</td><td>' . $tdValue . '</td> </tr>';
return $tableRow;
}
public function changeBgColorWhiteToBlue()
{
if ($this->color == 'D4E4F3') {
$this->color = '';
return '';
}
$this->color = 'D4E4F3';
return 'D4E4F3';
}
public function createTableRow($tdName)
{
return '<td>'. $tdName.'</td>';
}
}