Skip to content

Commit

Permalink
rewrite helper: search service by name
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Apr 11, 2018
1 parent 3f46460 commit 7a25aff
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ public static function parseKeyValueBlock(string $block, string $delimiter = ':'
*/
public static function searchService(array $services, string $serviceName) : ?Service
{
$neededObject = \array_filter($services, function (Service $service) use ($serviceName) {
return $service->getName() === $serviceName;
});
$item = null;
foreach($services as $service) {
if ($service->getName() === $serviceName) {
$item = $service;
break;
}
}

return $neededObject ? $neededObject[0] : null;
return $item;
}
}

0 comments on commit 7a25aff

Please sign in to comment.