├── .editorconfig ├── .gitignore ├── .idea ├── headfirst_design_php.iml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── README.md ├── ch01 ├── ShoppingCart │ ├── CreditCardStrategy.php │ ├── Item.php │ ├── PaymentStrategy.php │ ├── PaypalStrategy.php │ ├── ShoppingCart.php │ ├── composer.json │ └── index.php └── simUDuck │ ├── Duck.php │ ├── FlyBehavior.php │ ├── FlyNoWay.php │ ├── FlyRocketPowered.php │ ├── FlyWithWings.php │ ├── MallardDuck.php │ ├── ModelDuck.php │ ├── MuteQuack.php │ ├── QuackBehavior.php │ ├── Quacks.php │ ├── Squeak.php │ ├── composer.json │ └── index.php ├── ch02 └── Weather-O-Rama │ ├── CurrentConditionDisplay.php │ ├── DisplayElement.php │ ├── ForecastDisplay.php │ ├── HeatIndexDisplay.php │ ├── StatisticsDisplay.php │ ├── WeatherData.php │ ├── composer.json │ ├── heatindex.txt │ └── index.php ├── ch03 ├── PHP_IO_DECORATOR │ ├── LowerCaseInputStream.php │ ├── composer.json │ ├── index.php │ └── test.txt ├── StarbuzzCoffee │ ├── Beverage.php │ ├── CondimentDecorator.php │ ├── CondimentPrettyPrint.php │ ├── DarkRoast.php │ ├── Espresso.php │ ├── HouseBlend.php │ ├── Mocha.php │ ├── Soy.php │ ├── Whip.php │ ├── composer.json │ └── index.php └── decorator.jpg ├── ch04 ├── PizzaStore │ ├── CheesePizza.php │ ├── ChicagoPizzaIngredientFactory.php │ ├── ChicagoPizzaStore.php │ ├── Ingredients │ │ ├── Cheese.php │ │ ├── Cheese │ │ │ ├── MozzarellaCheese.php │ │ │ └── ReggianCheese.php │ │ ├── Clams.php │ │ ├── Clams │ │ │ ├── FreshClams.php │ │ │ └── FrozenClams.php │ │ ├── Dough.php │ │ ├── Dough │ │ │ ├── ThickCrustDough.php │ │ │ └── ThinCrustDough.php │ │ ├── Pepperoni.php │ │ ├── Pepperoni │ │ │ └── SlicedPepperoni.php │ │ ├── Sauce.php │ │ ├── Sauce │ │ │ ├── MarinaraSauce.php │ │ │ └── PulmTomatoSauce.php │ │ └── Veggies │ │ │ ├── BlackOlives.php │ │ │ ├── EggPlant.php │ │ │ ├── Garlic.php │ │ │ ├── Mushroom.php │ │ │ ├── Onion.php │ │ │ ├── RedPepper.php │ │ │ └── Spinach.php │ ├── NYPizzaIngredientFactory.php │ ├── NYPizzaStore.php │ ├── Pizza.php │ ├── PizzaIngredientFactory.php │ ├── PizzaStore.php │ ├── composer.json │ └── index.php ├── PizzaStoreFactoryMethod │ ├── ChicagoCheesePizza.php │ ├── ChicagoPizzaStore.php │ ├── NYCheesePizza.php │ ├── NYPizzaStore.php │ ├── Pizza.php │ ├── PizzaStore.php │ ├── composer.json │ └── index.php ├── abstract-factory-2.jpg ├── abstract-factory.jpg └── factory-method.jpg ├── ch05 ├── Choc-O-Holic │ ├── ChocolateBoiler.php │ ├── TestSingleton.php │ ├── composer.json │ └── index.php ├── singleton.jpg └── singletonDb │ ├── SingletonConnect.php │ ├── composer.json │ └── index.php ├── ch06 ├── BankTransaction │ ├── Acknowledge.php │ ├── Authenticate.php │ ├── Debit.php │ ├── ShareData.php │ ├── Transaction.php │ ├── TransactionExecutioner.php │ ├── composer.json │ └── index.php └── HomeAutomation │ ├── Command.php │ ├── Commands │ ├── CeilingFanHighCommand.php │ ├── CeilingFanMediumCommand.php │ ├── CeilingFanOffCommand.php │ ├── CeilingFanOnCommand.php │ ├── GarageDoorCloseCommand.php │ ├── GarageDoorOpenCommand.php │ ├── LightOffCommand.php │ ├── LightOnCommand.php │ ├── MacroCommand.php │ ├── NoCommand.php │ ├── StereoOffCommand.php │ └── StereoOnWithCDCommand.php │ ├── Receiver │ ├── CeilingFan.php │ ├── GarageDoor.php │ ├── Light.php │ └── Stereo.php │ ├── RemoteControl.php │ ├── SimpleRemoteControl.php │ ├── composer.json │ └── index.php ├── ch07 ├── HomeTheaterFacade │ ├── Components │ │ ├── Amplifier.php │ │ ├── CdPlayer.php │ │ ├── DvdPlayer.php │ │ ├── PopcornPopper.php │ │ ├── Projector.php │ │ ├── Screen.php │ │ ├── TheaterLights.php │ │ └── Tuner.php │ ├── HomeTheaterFacade.php │ ├── composer.json │ └── index.php └── TurkeyAdapter │ ├── Duck.php │ ├── DuckAdapter.php │ ├── MallardDuck.php │ ├── Turkey.php │ ├── TurkeyAdapter.php │ ├── WildTurkey.php │ ├── composer.json │ └── index.php ├── ch08 └── StarbuzzCoffeeRecipe │ ├── CaffeineBeverage.php │ ├── CaffeineBeverageWithHook.php │ ├── Coffee.php │ ├── CoffeeWithHook.php │ ├── Tea.php │ ├── TeaWithHook.php │ ├── composer.json │ └── index.php ├── ch09 ├── ObjectvilleDinerPancakeHouse │ ├── CompositeIterator.php │ ├── IteratorInterface.php │ ├── Menu.php │ ├── MenuComponent.php │ ├── MenuComponentsIterator.php │ ├── MenuItem.php │ ├── NullIterator.php │ ├── UnsupportedException.php │ ├── Waitress.php │ ├── composer.json │ └── index.php ├── composite_pattern.png └── iterator.png ├── ch10 ├── MightyGumball │ ├── GumballMachine.php │ ├── HasQuarterState.php │ ├── NoQuarterState.php │ ├── SoldOutState.php │ ├── SoldState.php │ ├── StateInterface.php │ ├── WinnerState.php │ ├── composer.json │ └── index.php └── state_pattern.png ├── ch11 └── MightyGumball │ ├── Client │ ├── GumballMachineProxy.php │ ├── GumballMonitor.php │ ├── JsonRequest.php │ ├── RequestInterface.php │ └── index.php │ ├── GumballMachineInterface.php │ ├── Service │ ├── GumballMachine.php │ ├── HasQuarterState.php │ ├── NoQuarterState.php │ ├── SoldOutState.php │ ├── SoldState.php │ ├── StateInterface.php │ └── WinnerState.php │ ├── composer.json │ ├── gm_boulder │ └── index.php │ ├── gm_santafe │ └── index.php │ └── gm_seattle │ └── index.php └── resources └── intoyourbrain.png /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = false 12 | 13 | [*.json] 14 | indent_style = space 15 | indent_size = 2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .vscode 3 | -------------------------------------------------------------------------------- /.idea/headfirst_design_php.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | true 44 | DEFINITION_ORDER 45 | 46 | 47 | 48 | 49 | 50 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |