Skip to content

Commit

Permalink
add 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 67b4cc6 commit 3f46460
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Ginfo;

use Ginfo\Info\Service;

class Common
{
/**
Expand Down Expand Up @@ -82,4 +84,18 @@ public static function parseKeyValueBlock(string $block, string $delimiter = ':'
}
return $tmp;
}

/**
* @param Service[] $services
* @param string $serviceName
* @return Service|null
*/
public static function searchService(array $services, string $serviceName) : ?Service
{
$neededObject = \array_filter($services, function (Service $service) use ($serviceName) {
return $service->getName() === $serviceName;
});

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

0 comments on commit 3f46460

Please sign in to comment.