Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
921 B

<?php
namespace App\SearchDisplace\Searchers;
class Searcher
{
protected $searchers;
protected $content;
public function __construct($searchers, $content)
{
$this->searchers = $searchers;
$this->content = $content;
ksort($this->searchers);
}
public function execute()
{
$mapper = new Mapper();
$validSearchers = $mapper->getSearchers();
// The object should contain the searcher name, other info, like the user input.
$dimensions = [];
foreach ($this->searchers as $orderNumber => $searcher) {
if ( ! in_array($searcher['key'], $validSearchers)) {
throw new \Exception('Invalid searcher: ' . $searcher['key']);
}
$dimensions[] = $searcher['key'];
}
$duckling = new Duckling();
return $duckling->execute($this->content, $dimensions);
}
}