20 lines
368 B
PHP
20 lines
368 B
PHP
|
<?php
|
||
|
class TextHelper
|
||
|
{
|
||
|
public static function isValidEmail($email)
|
||
|
{
|
||
|
$emailRegex = '/^[^@]+@[^@]+\.[^@]+$/';
|
||
|
return preg_match($emailRegex, $email);
|
||
|
}
|
||
|
|
||
|
public static function replaceTokens($text, array $tokens)
|
||
|
{
|
||
|
foreach ($tokens as $key => $value)
|
||
|
{
|
||
|
$token = '{' . $key . '}';
|
||
|
$text = str_replace($token, $value, $text);
|
||
|
}
|
||
|
return $text;
|
||
|
}
|
||
|
}
|