/** * @param Record[] $records * @param string|Filter $filter * * @return array */ public static function filterRecords(array $records, $filter) { if (is_string($filter)) { $filter = new PropertyFilter($filter); } $result = []; foreach ($records as $record) { if ($filter->match($record)) { $result[$record->getId()] = $record; } } return $result; }
public function testNumericalComparison() { $this->repository->selectContentType('example01'); $record1 = $this->repository->createRecord('New Record'); $record1->setProperty('source', '110'); $record2 = $this->repository->createRecord('Another Record'); $record2->setProperty('source', '10'); $record3 = $this->repository->createRecord('Another Record'); $record3->setProperty('source', '12'); $filter = new PropertyFilter('source < 111'); $this->assertTrue($filter->match($record1)); $this->assertTrue($filter->match($record2)); $this->assertTrue($filter->match($record3)); }