Skip to content

Use ConnectionFactory instead of creating socket inside the Connection class constructor #12

@hkulekci

Description

@hkulekci

https://www.reddit.com/r/PHP/comments/107ehex/comment/j3r2ksv/

Newing socket factory in the Connection constructor only to create a socket client and throw the socket factory away hints that there should be a ConnectionFactory instead. It should accept socket factory in constructor. And offer a createConnection method that would call createClient on the socket factory and pass the returned socket client instance to constructor of Connection and then return the connection instance.

The callback parameter of Connection constructor is also weird. Why don't you just call the callback code after obtaining the new Connection instance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions