pdf-finder/src/Filter/FilterParser.php

16 lines
340 B
PHP
Raw Normal View History

2021-03-23 21:58:40 +01:00
<?php
namespace Filter;
2021-04-08 15:36:57 +02:00
class FilterParser
2021-03-23 21:58:40 +01:00
{
2021-04-08 15:36:57 +02:00
public function parse(string $string): DocumentFilter
2021-03-23 21:58:40 +01:00
{
if (preg_match('/^.+=.*$/', $string)) {
2021-04-08 15:36:57 +02:00
[$prop, $term] = explode('=', $string, 2);
2021-03-23 21:58:40 +01:00
return new SpecificFilter(trim($prop), trim($term));
}
return new GenericFilter($string);
}
}