Files
core/app/CMS/Handlers/Search/Search.php

26 lines
582 B
PHP

<?php
namespace App\CMS\Handlers\Search;
use App\CMS\Handlers\Contracts\SearchHandler;
use Symfony\Component\Process\Exception\InvalidArgumentException;
abstract class Search implements SearchHandler
{
/**
* Tokenize string for usage in LIKE clausules
*
* @param $term
*
* @return string
*/
protected function tokenize($term)
{
$term = trim($term);
if (empty($term)) {
throw new InvalidArgumentException(trans('search.emptyString'));
}
return '%' . str_replace(' ', '%', $term) . '%';
}
}