You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code returns null when a factory was already instantiated. I can see some major problems with this approach:
It is not intuitive for the developer
This violates the method contract as specified in the @return docblock annotation tag. The annotation specifies that the return type is an instance of SplitFactoryInterface
My suggestion would be: Instead of tracking the instantiation of the factories by using a flag (KEY_FACTORY_TRACKER) we would keep a reference to the instantiated object in the container, so that whenever an user of the SDK tries to create multiple factories, we simply return the last created factory
Another approach would be to create a new static method called singleton to make this behavior more explicit.