Skip to content

Instantly share code, notes, and snippets.

@toin0u
Created May 14, 2013 19:50
Show Gist options
  • Save toin0u/5578940 to your computer and use it in GitHub Desktop.
Save toin0u/5578940 to your computer and use it in GitHub Desktop.
<?php
interface ProviderInterface
{
public function foo();
}
abstract class AbstractProvider implements ProviderInterface
{
public function bar()
{
return "bar\n";
}
// foo() is not implemented here
}
class MyProvider extends AbstractProvider
{
public function foo()
{
return "foo\n";
}
}
$provider = new MyProvider;
echo $provider->foo(); // foo
echo $provider->bar(); // bar
@toin0u
Copy link
Author

toin0u commented May 15, 2013

I totaly agree :)

I do prefer having the interface defined in the concrete implementation

This implementation gives flexibility :)

If I want to drop the abstract class for some reasons, I can

Thanks for this explanation.

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