Is your feature request related to a problem? Please describe.
Currently, the connection object is also responsible for resource configuration, creation and usage without a proper abstraction around it. This leads to the following problems:
- Increased coupling. The code that represents different modules are mixed in one, which makes it harder to re-use (for example socket configuration and creation) and maintain.
- Code testability. Since, all the read/write operations performed directly from stream in connection object, it's impossible to mock it and test the actual business-logic (handshake, protocol parsing, exception handling etc.) without performing actual read/write.
Describe the solution you'd like
- Introduce PSR-7 (as a standard in PHP) compatible abstraction for streams to avoid direct streams usage and instead provide a proper API to decouple streams from connection.
- Introduce Stream Factory abstraction to separate a logic of configuration and creation of actual stream instance.
- Move a code to the right places.
- Added missing test coverage for connection
Describe alternatives you've considered
Do not use PSR-7 interface and instead provide a custom one.
Additional context
This feature requires a new dependency to be introduced, so we can follow PSR-7 interface - php-fig/http-message
Is your feature request related to a problem? Please describe.
Currently, the connection object is also responsible for resource configuration, creation and usage without a proper abstraction around it. This leads to the following problems:
Describe the solution you'd like
Describe alternatives you've considered
Do not use PSR-7 interface and instead provide a custom one.
Additional context
This feature requires a new dependency to be introduced, so we can follow PSR-7 interface -
php-fig/http-message