Skip to content

Instantly share code, notes, and snippets.

@giorgiosironi
Created February 22, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giorgiosironi/5015697 to your computer and use it in GitHub Desktop.
Save giorgiosironi/5015697 to your computer and use it in GitHub Desktop.
class MyClass
{
function __construct(Collaborator %collaborator)
{
}
}
// vs.
class MyClass
{
function doSomething(Collaborator $collaborator)
{
}
}
@giorgiosironi
Copy link
Author

MyClass is composed by SomeHttpAction, which creates an implementation of Collaborator depending on some input parameter. SomeHttpAction and MyClass are created at the startup, while Collaborator is created after analyzing the request: that's why I find it handy to inject it as a parameter; from the point of view of MyClass nothing really changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment