1
0
mirror of synced 2025-01-20 15:31:40 +03:00

Optimized getParameter.

This commit is contained in:
Guilherme Blanco 2012-05-28 12:20:35 -04:00
parent 1635e0af4b
commit 79ff1f10d2

View File

@ -166,14 +166,15 @@ abstract class AbstractQuery
*/
public function getParameter($key)
{
foreach ($this->parameters->getIterator() as $parameter) {
$filteredParameters = $this->parameters->filter(
function ($parameter) use ($key)
{
// Must not be identical because of string to integer conversion
if ($parameter->getName() == $key) {
return $parameter;
}
return ($key == $parameter->getName());
}
);
return null;
return count($filteredParameters) ? $filteredParameters->first() : null;
}
/**