Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit a43fec1

Browse files
Add new method getListenerByPort
1 parent 832f8c0 commit a43fec1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Config.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ public function __construct(array $data)
4949
$this->_upstreams = $data['upstreams'] ?? [];
5050
}
5151

52+
/**
53+
* Get listener by port
54+
*
55+
* @param int $port
56+
* @return Listener|null
57+
*/
58+
public function getListenerByPort(int $port): Listener|null
59+
{
60+
foreach ($this->_listeners as $listener) {
61+
if ($listener->getPort() == $port) {
62+
return $listener;
63+
}
64+
}
65+
66+
return null;
67+
}
68+
5269
/**
5370
* Get listeners from config
5471
*

src/Interfaces/ConfigInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
namespace Pavlusha311245\UnitPhpSdk\Interfaces;
44

5+
use Pavlusha311245\UnitPhpSdk\Config\Listener;
6+
57
interface ConfigInterface
68
{
79
public function getListeners();
810

11+
public function getListenerByPort(int $port): Listener|null;
12+
913
public function getRoutes();
1014

1115
public function getRoute($routeName);

0 commit comments

Comments
 (0)