for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the jquery-datatables-bundle package.
*
* (c) 2018 WEBEWEB
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WBW\Bundle\JQuery\DataTablesBundle\Factory;
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesSearch;
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesSearchInterface;
use WBW\Library\Core\Argument\BooleanHelper;
* DataTables factory.
* @author webeweb <https://github.com/webeweb/>
* @package WBW\Bundle\JQuery\DataTablesBundle\Factory
class DataTablesFactory {
* Creates a new search.
* @param array $rawSearch The raw search.
* @return DataTablesSearchInterface Returns a search instance.
public static function newSearch(array $rawSearch) {
// Initialize a DataTables search.
$dtSearch = new DataTablesSearch();
// Determines if the raw search is valid.
if (false === array_key_exists(DataTablesSearchInterface::DATATABLES_PARAMETER_REGEX, $rawSearch)) {
return $dtSearch;
}
if (false === array_key_exists(DataTablesSearchInterface::DATATABLES_PARAMETER_VALUE, $rawSearch)) {
// Set the search.
$dtSearch->setRegex(BooleanHelper::parseString($rawSearch[DataTablesSearchInterface::DATATABLES_PARAMETER_REGEX]));
$dtSearch->setValue($rawSearch[DataTablesSearchInterface::DATATABLES_PARAMETER_VALUE]);
// Return the search.