This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //src/Doctrine/CustomerIdGenerator.php | |
| namespace App\Doctrine; | |
| use Doctrine\ORM\EntityManager; | |
| use Doctrine\ORM\Id\AbstractIdGenerator; | |
| class CustomerIdGenerator extends AbstractIdGenerator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //src/Entity/Customer.php | |
| //... | |
| class Customer | |
| { | |
| /** | |
| * @ORM\Id() | |
| * @ORM\GeneratedValue("CUSTOM") | |
| * @ORM\Column(type="integer") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //tests/Doctrine/CustomerIdGeneratorTest.php | |
| namespace App\Tests\Doctrine; | |
| use App\Entity\Customer; | |
| use Doctrine\ORM\EntityManagerInterface; | |
| use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
| class CustomerIdGeneratorTest extends KernelTestCase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Consumer.php | |
| class Consumer | |
| { | |
| private $coffee; | |
| public function __construct(CoffeeInterface $coffee) | |
| { | |
| $this->coffee = $coffee; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //AtHomeCustomer.php | |
| class AtHomeConsumer | |
| { | |
| public function readyToWork() | |
| { | |
| echo 'I am stay at home!' . PHP_EOL; | |
| $egg = new Egg(); | |
| $coffee = new EggCoffee($egg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //AtCoffeeShopConsumer.php | |
| class AtCoffeeShopConsumer | |
| { | |
| private $coffee; | |
| public function __construct(CoffeeInterface $coffee) | |
| { | |
| $this->coffee = $coffee; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //coffee_shop_context.php | |
| //to load Class & Interface file when we need them | |
| spl_autoload_register(function ($class_name) { | |
| include $class_name . '.php'; | |
| }); | |
| //at the coffee shop | |
| $egg = new Egg(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Milk.php | |
| class Milk | |
| { | |
| public function taste() | |
| { | |
| echo 'It tastes milkyyy...' . PHP_EOL; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //MilkCoffee.php | |
| class MilkCoffee implements CoffeeInterface | |
| { | |
| private $milk; | |
| public function __construct(Milk $milk) | |
| { | |
| $this->milk = $milk; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //coffee_shop_another_day_context.php | |
| //to load Class & Interface file when we need them | |
| spl_autoload_register(function ($class_name) { | |
| include $class_name . '.php'; | |
| }); | |
| //at the coffee shop in another day | |
| $milk = new Milk(); |