MAKS\AmqpAgent\RPC\AbstractEndpoint::on
Hooking method based on events to manipulate the request/response during the endpoint/message life cycle.
Check out `self::$events` via `self::getEvents()` after processing at least one request/response to see all available events. The parameters will be passed to the callback as follows: 1. `$listenedOnObject` (first segment of event name e.g. `'connection.after.open'` will be `$connection`), 2. `$calledOnObject` (the object this method was called on e.g. `$endpoint`), 3. `$eventName` (the event was listened on e.g. `'connection.after.open'`). ``` $endpoint->on('connection.after.open', function ($connection, $endpoint, $event) { ... }); ```
Signature
public function on(string
$event,
callable
$callback )
Parameters
$event
— string- The event to listen on.
$callback
— callable- The callback to execute.
Returns
- AbstractEndpoint
Test Coverage
Information
- Coverage: 7/7 Lines (100%)
- Tests: 6
- Passed: 6 (100%)
Tests
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\AbstractEndpointTest::testOnMethodExecutesACallbackSuccessfully
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ClientEndpointTest::testConnectMethodReturnsSelf
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ClientEndpointTest::testRequestMethodViaAliasMethodCall
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ClientEndpointTest::testAnExceptionIsRaisedIfCorrelationIdOfTheResponseIsNotTheSameAsTheRequest
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ServerEndpointTest::testRespondMethodViaAliasMethodServe
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ServerEndpointTest::testAnExceptionIsRaisedIfPassedCallbackDoesNotReturnString
Violations
PHPMessDetector
Line | Rule | Message |
---|---|---|
275 - 288 | ShortMethodName | Avoid using short method names like AbstractEndpoint::on(). The configured minimum method name length is 3. |