/**
* Creates and filters the configuration collection
*
* @param object|PaymentMethodInterface $paymentMethod
* @param array $values
*
* @return Collection|static
*/
protected function createConfigurationCollection(PaymentMethodInterface $paymentMethod, array $values = [])
{
$processor = $paymentMethod->getProcessor();
$collection = new ArrayCollection();
foreach ($values as $name => $value) {
$configuration = $this->factory->create();
$configuration->setName($name);
$configuration->setPaymentMethod($paymentMethod);
$configuration->setValue($value);
$collection->add($configuration);
}
return $collection->filter(function (PaymentMethodConfigurationInterface $configuration) use($processor) {
return substr($configuration->getName(), 0, strlen($processor)) === $processor;
});
}