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.
115 lines
2.7 KiB
115 lines
2.7 KiB
<?php
|
|
|
|
namespace App\SearchDisplace\Searchers;
|
|
|
|
class Mapper
|
|
{
|
|
protected $mapper;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->mapper = [
|
|
'amount-of-money' => [
|
|
'name' => 'Amount Of Money',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'credit-card-number' => [
|
|
'name' => 'Credit Card Number',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'distance' => [
|
|
'name' => 'Distance',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'duration' => [
|
|
'name' => 'Duration',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'email' => [
|
|
'name' => 'Email',
|
|
'param' => SearchersCollection::PARAM_OPTIONAL
|
|
],
|
|
|
|
'numeral' => [
|
|
'name' => 'Numeral',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'ordinal' => [
|
|
'name' => 'Ordinal',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'phone-number' => [
|
|
'name' => 'Phone Number',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'quantity' => [
|
|
'name' => 'Quantity',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'temperature' => [
|
|
'name' => 'Temperature',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'time' => [
|
|
'name' => 'Time',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'url' => [
|
|
'name' => 'URL',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
|
|
'volume' => [
|
|
'name' => 'Volume',
|
|
'param' => SearchersCollection::PARAM_REQUIRED
|
|
],
|
|
];
|
|
}
|
|
|
|
public function getSearchers()
|
|
{
|
|
return array_keys($this->mapper);
|
|
}
|
|
|
|
public function all()
|
|
{
|
|
$items = [];
|
|
|
|
foreach ($this->mapper as $key => $value) {
|
|
$items[$key] = [
|
|
'id' => $key,
|
|
'name' => $value['name'],
|
|
'param' => $value['param']
|
|
];
|
|
}
|
|
|
|
return $items;
|
|
}
|
|
|
|
public function has($id)
|
|
{
|
|
return in_array($id, $this->getSearchers());
|
|
}
|
|
|
|
public function get($id)
|
|
{
|
|
if ( ! $this->has($id)) {
|
|
return null;
|
|
}
|
|
|
|
return array_merge($this->mapper[$id], [
|
|
'id' => $id,
|
|
'description' => '',
|
|
]);
|
|
}
|
|
}
|