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.
 
 
 
 
 
 

57 lines
1.3 KiB

<?php
namespace App\SearchDisplace\Searchers;
class SearchersCollection
{
const PARAM_REQUIRED = 'required';
const PARAM_OPTIONAL = 'optional';
public function all()
{
$collection = [];
foreach ((new SearchersStorage())->all() as $item) {
$collection[] = array_merge($item, [
'type' => 'custom',
]);
}
foreach ((new Mapper)->all() as $item) {
$collection[] = array_merge($item, [
'type' => 'duckling',
]);
}
return $collection;
}
public function get($id)
{
$searcherStorage = new SearchersStorage();
if ($searcherStorage->has($id)) {
return array_merge($searcherStorage->get($id), [
'type' => 'custom',
]);
}
$ducklingMapper = new Mapper();
if ($ducklingMapper->has($id)) {
return array_merge($ducklingMapper->get($id), [
'type' => 'duckling',
]);
}
return null;
}
public function has($id)
{
$searcherStorage = new SearchersStorage();
$ducklingMapper = new Mapper();
return $searcherStorage->has($id) || $ducklingMapper->has($id);
}
}