File tree Expand file tree Collapse file tree 2 files changed +1
-39
lines changed Expand file tree Collapse file tree 2 files changed +1
-39
lines changed Original file line number Diff line number Diff line change @@ -108,32 +108,10 @@ public function create(string $input): iterable
108108 }
109109 }
110110
111- /**
112- * Creates a message by its type and parameters.
113- *
114- * @template T of HasMethodInterface
115- *
116- * @param class-string<T> $messageType
117- * @param RequestData $data
118- *
119- * @return T
120- */
121- public function createByType (string $ messageType , array $ data ): HasMethodInterface
122- {
123- if (\in_array ($ messageType , $ this ->registeredMessages , true )) {
124- $ data ['jsonrpc ' ] = MessageInterface::JSONRPC_VERSION ;
125- $ data ['method ' ] = $ messageType ::getMethod ();
126-
127- return $ messageType ::fromArray ($ data );
128- }
129-
130- throw new InvalidArgumentException (\sprintf ('Message type "%s" is not registered. ' , $ messageType ));
131- }
132-
133111 /**
134112 * @return class-string<HasMethodInterface>
135113 */
136- private function getType (string $ method ): string
114+ private function getType (string $ method/**/ ): string
137115 {
138116 foreach (self ::REGISTERED_MESSAGES as $ type ) {
139117 if ($ type ::getMethod () === $ method ) {
Original file line number Diff line number Diff line change @@ -82,22 +82,6 @@ public function testBatchMissingMethod()
8282 $ this ->assertInstanceOf (InitializedNotification::class, $ result );
8383 }
8484
85- public function testCreateByType (): void
86- {
87- $ result = $ this ->factory ->createByType (InitializedNotification::class, []);
88- $ this ->assertInstanceOf (InitializedNotification::class, $ result );
89- }
90-
91- public function testCreateByTypeWithMissingData (): void
92- {
93- $ this ->expectException (InvalidArgumentException::class);
94- $ this ->expectExceptionMessage (
95- 'Invalid or missing "requestId" parameter for "notifications/cancelled" notification. '
96- );
97-
98- $ this ->factory ->createByType (CancelledNotification::class, []);
99- }
100-
10185 /**
10286 * @param iterable<mixed> $items
10387 */
You can’t perform that action at this time.
0 commit comments