Skip to content

Instantly share code, notes, and snippets.

@vonglasow
Last active August 29, 2015 14:02
Show Gist options
  • Save vonglasow/f04535323efab24f1e54 to your computer and use it in GitHub Desktop.
Save vonglasow/f04535323efab24f1e54 to your computer and use it in GitHub Desktop.
Factory
<?php
class Factory
{
public function create()
{
$this->context->create();
}
public function setContext($context)
{
$this->context = $context;
}
}
SlotsInterface {
public function create();
}
class OW implements SlotsInterface
{
public function create()
{
echo 'create two slots' . PHP_EOL;
}
}
class AR implements SlotsInterface
{
public function create()
{
echo 'Create four slots' . PHP_EOL;
}
}
//Usage
$f = new Factory();
$f->setContext(new AR());
$f->create(); // Four slots created
$f->setContext(new OW());
$f->create(); // two slots created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment