$result = strpos(strtolower($listing->getTitle()), strtolower($product->getModel()));
if (false !== $result) {
$matches++;
}
if (2 === $matches) {
$matchingListings[] = $listing;
// has been matched, remove listing from future searches
unset($this->listings[$key]);
}
}
if (count($matchingListings)) {
// 1 or more matches were found, add to output
$ret[] = array(
'product' => $product,
'listings' => $matchingListings
);
}
}
return $ret;
}
/**
* Convert plain nested array to array of objects
*
* @param array $data
* @param int $type
* @return array
* @throws \InvalidArgumentException
*/
protected function normalizeRawData(array $data, $type)
{
// build model for each item
return array_map(function($value) use ($type) {
switch ($type) {
case ProListMatcher::TYPE_PRODUCT:
return new Product($value);
case ProListMatcher::TYPE_LISTING: