├── .gitattributes ├── 9781484267905.jpg ├── Contributing.md ├── LICENSE.txt ├── composer.json ├── composer.lock ├── contents.txt ├── errata.md ├── readme.md ├── src ├── ch03 │ ├── batch01 │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch02 │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch03 │ │ ├── Runner.php │ │ ├── SampleClass.php │ │ └── ShopProduct.php │ ├── batch04 │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch04_1 │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch04_2 │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch05 │ │ ├── AddressManager.php │ │ ├── Runner.php │ │ └── resolve.xml │ ├── batch06 │ │ ├── AddressManager.php │ │ ├── Runner.php │ │ └── resolve.xml │ ├── batch07 │ │ ├── AddressManager.php │ │ ├── Runner.php │ │ └── ShopProductWriter.php │ ├── batch08 │ │ ├── AddressManager.php │ │ ├── Runner.php │ │ ├── ShopProductWriter.php │ │ └── Wrong.php │ ├── batch09 │ │ ├── AddressManager.php │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ └── resolve.xml │ ├── batch10 │ │ ├── ConfReader.php │ │ ├── Point.php │ │ ├── Runner.php │ │ └── Storage.php │ ├── batch11 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── Point.php │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ ├── ShopProductWriter.php │ │ └── Storage.php │ ├── batch12 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ └── Storage.php │ ├── batch13 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ └── Storage.php │ ├── batch14 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── ShopProduct.php │ │ ├── ShopProductWriter.php │ │ └── Storage.php │ └── batch15 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── ShopProduct.php │ │ ├── ShopProductWriter.php │ │ └── Storage.php ├── ch04 │ ├── batch01 │ │ ├── Runner.php │ │ ├── StaticExample.php │ │ └── StaticExample2.php │ ├── batch02 │ │ ├── BookProduct.php │ │ ├── CdProduct.php │ │ ├── DbGenerate.php │ │ ├── Runner.php │ │ └── ShopProduct.php │ ├── batch03 │ │ ├── ErroredWriter.php │ │ ├── Runner.php │ │ ├── ShopProductWriter.php │ │ ├── TextProductWriter.php │ │ └── XmlProductWriter.php │ ├── batch05 │ │ ├── Bookable.php │ │ ├── Chargeable.php │ │ ├── Consultancy.php │ │ ├── Document.php │ │ ├── DomainObject.php │ │ ├── Runner.php │ │ ├── Shipping.php │ │ ├── ShopProduct.php │ │ ├── TimedService.php │ │ └── User.php │ ├── batch06 │ │ ├── Document.php │ │ ├── DomainObject.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── ShopProduct.php │ │ ├── User.php │ │ └── UtilityService.php │ ├── batch06_1 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── ShopProduct.php │ │ └── UtilityService.php │ ├── batch06_2 │ │ ├── IdentityTrait.php │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── ShopProduct.php │ │ └── UtilityService.php │ ├── batch06_3 │ │ ├── IdentityObject.php │ │ ├── IdentityTrait.php │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── ShopProduct.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_4 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_5 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_6 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_7 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_8 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch06_9 │ │ ├── PriceUtilities.php │ │ ├── Runner.php │ │ ├── Service.php │ │ ├── TaxTools.php │ │ └── UtilityService.php │ ├── batch07 │ │ ├── Document.php │ │ ├── DomainObject.php │ │ ├── Runner.php │ │ ├── SpreadSheet.php │ │ └── User.php │ ├── batch08 │ │ ├── Mailer.php │ │ ├── ProcessSale.php │ │ ├── Product.php │ │ ├── Runner.php │ │ ├── Totalizer.php │ │ ├── Totalizer2.php │ │ └── Totalizer3.php │ ├── batch09 │ │ ├── Conf.php │ │ ├── Runner.php │ │ └── conf01.xml │ ├── batch10 │ │ ├── Conf.php │ │ ├── Runner.php │ │ └── conf01.xml │ ├── batch11 │ │ ├── Conf.php │ │ ├── ConfException.php │ │ ├── FileException.php │ │ ├── Runner.php │ │ ├── XmlException.php │ │ ├── conf.broken.xml │ │ ├── conf01.xml │ │ └── log.txt │ ├── batch12 │ │ ├── Conf.php │ │ ├── ConfException.php │ │ ├── FileException.php │ │ ├── Runner.php │ │ ├── XmlException.php │ │ └── conf.broken.xml │ ├── batch13 │ │ ├── Checkout.php │ │ ├── IllegalCheckout.php │ │ └── Runner.php │ ├── batch14 │ │ ├── Checkout.php │ │ ├── IllegalCheckout.php │ │ └── Runner.php │ ├── batch15 │ │ ├── Person.php │ │ └── Runner.php │ ├── batch16 │ │ ├── Address.php │ │ └── Runner.php │ ├── batch17 │ │ ├── Person.php │ │ └── Runner.php │ ├── batch18 │ │ ├── OtherPerson.php │ │ ├── Person.php │ │ ├── PersonWriter.php │ │ └── Runner.php │ ├── batch19 │ │ ├── CopyMe.php │ │ ├── Person.php │ │ └── Runner.php │ ├── batch20 │ │ ├── Person.php │ │ └── Runner.php │ ├── batch21 │ │ ├── Account.php │ │ ├── Person.php │ │ ├── Runner.php │ │ └── ShallowPerson.php │ ├── batch22 │ │ ├── Person.php │ │ ├── Runner.php │ │ └── StringThing.php │ ├── batch23 │ │ ├── ProcessSale.php │ │ ├── Product.php │ │ └── Runner.php │ └── batch24 │ │ ├── Person.php │ │ ├── PersonWriter.php │ │ └── Runner.php ├── ch05 │ ├── batch01 │ │ ├── my │ │ │ └── Outputter.php │ │ └── useful │ │ │ └── Outputter.php │ ├── batch02 │ │ ├── my │ │ │ └── Outputter.php │ │ └── useful │ │ │ └── Outputter.php │ ├── batch03 │ │ ├── my │ │ │ └── Outputter.php │ │ └── useful │ │ │ └── Outputter.php │ ├── batch04 │ │ ├── Autoload.php │ │ ├── Autoload2.php │ │ ├── Autoload3.php │ │ ├── Autoload3_1.php │ │ ├── Autoload4.php │ │ ├── Blah.php │ │ ├── Debug.php │ │ ├── Lister.php │ │ ├── Multi.php │ │ ├── Runner.php │ │ ├── Writerer.php │ │ ├── Writerer2.php │ │ ├── business │ │ │ ├── Customer.php │ │ │ └── User.php │ │ ├── clash.php │ │ ├── client │ │ │ └── FromClient.php │ │ ├── my │ │ │ └── Outputter.php │ │ ├── unclash.php │ │ ├── useful │ │ │ └── Outputter.php │ │ ├── util │ │ │ ├── Blah.php │ │ │ ├── Debug.php │ │ │ ├── InSame.php │ │ │ ├── LocalPath.php │ │ │ ├── TreeLister.php │ │ │ ├── WebTools.php │ │ │ └── writer.php │ │ └── writer.php │ ├── batch05 │ │ ├── CdProduct.php │ │ ├── Local.php │ │ ├── LocalNsEg.php │ │ ├── Runner.php │ │ ├── tasks │ │ │ └── Task.php │ │ └── util │ │ │ ├── Writer.php │ │ │ └── db │ │ │ └── Querier.php │ ├── batch06 │ │ ├── Delegator.php │ │ ├── OtherShop.php │ │ └── Runner.php │ ├── batch07 │ │ ├── ClassInfo.php │ │ ├── Delegator.php │ │ ├── OtherShop.php │ │ ├── ReflectionUtil.php │ │ └── Runner.php │ ├── batch08 │ │ ├── FtpModule.php │ │ ├── Module.php │ │ ├── ModuleRunner.php │ │ ├── Person.php │ │ ├── PersonModule.php │ │ └── Runner.php │ └── batch09 │ │ ├── ApiInfo.php │ │ ├── Person.php │ │ └── Runner.php ├── ch06 │ ├── batch01 │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ ├── paramreader.php │ │ └── params.txt │ ├── batch02 │ │ ├── Runner.php │ │ ├── paramreader.php │ │ ├── params.txt │ │ └── texttest.proc.xml │ └── batch03 │ │ ├── ParamHandler.php │ │ ├── Runner.php │ │ ├── TextParamHandler.php │ │ ├── XmlParamHandler.php │ │ ├── newparams.txt │ │ ├── params.txt │ │ └── params.xml ├── ch08 │ ├── batch01 │ │ ├── Lecture.php │ │ ├── Lesson.php │ │ ├── Runner.php │ │ └── Seminar.php │ ├── batch02 │ │ ├── CostStrategy.php │ │ ├── FixedCostStrategy.php │ │ ├── Lecture.php │ │ ├── Lesson.php │ │ ├── MailNotifier.php │ │ ├── Notifier.php │ │ ├── RegistrationMgr.php │ │ ├── Runner.php │ │ ├── Seminar.php │ │ ├── TextNotifier.php │ │ └── TimedCostStrategy.php │ └── batch03 │ │ └── Lesson.php ├── ch09 │ ├── batch01 │ │ ├── Employee.php │ │ ├── Minion.php │ │ ├── NastyBoss.php │ │ └── Runner.php │ ├── batch02 │ │ ├── CluedUp.php │ │ ├── Employee.php │ │ ├── Minion.php │ │ ├── NastyBoss.php │ │ └── Runner.php │ ├── batch03 │ │ ├── CluedUp.php │ │ ├── Employee.php │ │ ├── Minion.php │ │ ├── NastyBoss.php │ │ ├── Runner.php │ │ ├── ShopProduct.php │ │ └── WellConnected.php │ ├── batch04 │ │ ├── Preferences.php │ │ └── Runner.php │ ├── batch05 │ │ ├── Preferences.php │ │ ├── PreferencesImpl.php │ │ ├── PreferencesMock.php │ │ └── Runner.php │ ├── batch06 │ │ ├── ApptEncoder.php │ │ ├── BloggsApptEncoder.php │ │ ├── CommsManager.php │ │ ├── MegaApptEncoder.php │ │ └── Runner.php │ ├── batch07 │ │ ├── ApptEncoder.php │ │ ├── BloggsApptEncoder.php │ │ ├── CommsManager.php │ │ ├── MegaApptEncoder.php │ │ └── Runner.php │ ├── batch08 │ │ ├── ApptEncoder.php │ │ ├── BloggsApptEncoder.php │ │ ├── BloggsCommsManager.php │ │ ├── CommsManager.php │ │ └── Runner.php │ ├── batch09 │ │ ├── ApptEncoder.php │ │ ├── BloggsApptEncoder.php │ │ ├── BloggsCommsManager.php │ │ ├── CommsManager.php │ │ ├── MegaApptEncoder.php │ │ ├── MegaCommsManager.php │ │ └── Runner.php │ ├── batch10 │ │ ├── ApptEncoder.php │ │ ├── BloggsApptEncoder.php │ │ ├── BloggsCommsManager.php │ │ ├── CommsManager.php │ │ ├── Encoder.php │ │ ├── MegaApptEncoder.php │ │ └── Runner.php │ ├── batch11 │ │ ├── EarthForest.php │ │ ├── EarthPlains.php │ │ ├── EarthSea.php │ │ ├── Forest.php │ │ ├── MarsForest.php │ │ ├── MarsPlains.php │ │ ├── MarsSea.php │ │ ├── Plains.php │ │ ├── Runner.php │ │ ├── Sea.php │ │ └── TerrainFactory.php │ ├── batch12 │ │ ├── Contained.php │ │ ├── Container.php │ │ ├── EarthForest.php │ │ ├── EarthPlains.php │ │ ├── EarthSea.php │ │ ├── Forest.php │ │ ├── MarsForest.php │ │ ├── MarsPlains.php │ │ ├── MarsSea.php │ │ ├── Plains.php │ │ ├── Runner.php │ │ ├── Sea.php │ │ └── TerrainFactory.php │ ├── batch13 │ │ ├── AppConfig.php │ │ ├── Runner.php │ │ └── Settings.php │ ├── batch14 │ │ ├── AppointmentMaker.php │ │ ├── AppointmentMaker2.php │ │ ├── ObjectAssembler.php │ │ ├── Runner.php │ │ └── objects.xml │ ├── batch14_1 │ │ ├── AppointmentMaker.php │ │ ├── AppointmentMaker2.php │ │ ├── ObjectAssembler.php │ │ ├── Runner.php │ │ └── objects.xml │ └── batch15 │ │ ├── AppointmentMaker.php │ │ ├── AppointmentMaker2.php │ │ ├── Inject.php │ │ ├── InjectConstructor.php │ │ ├── ObjectAssembler.php │ │ ├── Runner.php │ │ ├── TerrainFactory.php │ │ └── objects.xml ├── ch10 │ ├── batch01 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── LaserCannonUnit.php │ │ ├── Runner.php │ │ └── Unit.php │ ├── batch02 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── LaserCannonUnit.php │ │ └── Unit.php │ ├── batch03 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── Runner.php │ │ ├── Soldier.php │ │ ├── Tank.php │ │ ├── Unit.php │ │ └── UnitException.php │ ├── batch04 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── LaserCannonUnit.php │ │ ├── Runner.php │ │ ├── Soldier.php │ │ ├── Tank.php │ │ ├── Unit.php │ │ └── UnitException.php │ ├── batch05 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── Cavalry.php │ │ ├── CompositeUnit.php │ │ ├── LaserCannonUnit.php │ │ ├── Runner.php │ │ ├── Soldier.php │ │ ├── Tank.php │ │ ├── TroopCarrier.php │ │ ├── Unit.php │ │ ├── UnitException.php │ │ └── UnitScript.php │ ├── batch06 │ │ ├── DiamondDecorator.php │ │ ├── DiamondPlains.php │ │ ├── Plains.php │ │ ├── PollutedPlains.php │ │ ├── PollutionDecorator.php │ │ ├── Runner.php │ │ ├── Tile.php │ │ └── TileDecorator.php │ ├── batch07 │ │ ├── AuthenticateRequest.php │ │ ├── DecorateProcess.php │ │ ├── LogRequest.php │ │ ├── MainProcess.php │ │ ├── ProcessRequest.php │ │ ├── RequestHelper.php │ │ ├── Runner.php │ │ └── StructureRequest.php │ └── batch08 │ │ ├── ProductFacade.php │ │ ├── Runner.php │ │ ├── legacy.php │ │ ├── test.txt │ │ └── test2.txt ├── ch11 │ ├── batch01 │ │ ├── BooleanAndExpression.php │ │ ├── BooleanEqualsExpression.php │ │ ├── BooleanOrExpression.php │ │ ├── Expression.php │ │ ├── InterpreterContext.php │ │ ├── LiteralExpression.php │ │ ├── OperatorExpression.php │ │ ├── Runner.php │ │ └── VariableExpression.php │ ├── batch02 │ │ ├── AVQuestion.php │ │ ├── MarkLogicMarker.php │ │ ├── Marker.php │ │ ├── MatchMarker.php │ │ ├── Question.php │ │ ├── RegexpMarker.php │ │ ├── Runner.php │ │ └── TextQuestion.php │ ├── batch03 │ │ ├── Login.php │ │ └── Runner.php │ ├── batch04 │ │ ├── Logger.php │ │ ├── Login.php │ │ ├── Notifier.php │ │ └── Runner.php │ ├── batch05 │ │ ├── GeneralLogger.php │ │ ├── Login.php │ │ ├── LoginAnalytics.php │ │ ├── LoginObserver.php │ │ ├── Observable.php │ │ ├── Observer.php │ │ ├── PartnershipTool.php │ │ ├── Runner.php │ │ └── SecurityMonitor.php │ ├── batch06 │ │ ├── GeneralLogger.php │ │ ├── Login.php │ │ ├── LoginObserver.php │ │ ├── PartnershipTool.php │ │ ├── Runner.php │ │ └── SecurityMonitor.php │ ├── batch07 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── Cavalry.php │ │ ├── CompositeUnit.php │ │ ├── LaserCanonUnit.php │ │ ├── Runner.php │ │ ├── TroopCarrier.php │ │ ├── Unit.php │ │ └── UnitException.php │ ├── batch08 │ │ ├── Archer.php │ │ ├── Army.php │ │ ├── ArmyVisitor.php │ │ ├── Cavalry.php │ │ ├── CompositeUnit.php │ │ ├── LaserCanonUnit.php │ │ ├── Runner.php │ │ ├── TaxCollectionVisitor.php │ │ ├── TextDumpArmyVisitor.php │ │ ├── TroopCarrier.php │ │ ├── Unit.php │ │ └── UnitException.php │ ├── batch09 │ │ ├── AccessManager.php │ │ ├── Command.php │ │ ├── CommandContext.php │ │ ├── CommandFactory.php │ │ ├── CommandNotFoundException.php │ │ ├── Controller.php │ │ ├── MessageSystem.php │ │ ├── Registry.php │ │ ├── Runner.php │ │ ├── User.php │ │ └── commands │ │ │ ├── DefaultCommand.php │ │ │ ├── FeedbackCommand.php │ │ │ └── LoginCommand.php │ ├── batch10 │ │ ├── Runner.php │ │ ├── TileForces.php │ │ └── UnitAcquisition.php │ ├── batch11 │ │ ├── TileForces.php │ │ └── UnitAcquisition.php │ ├── batch12 │ │ ├── NullUnit.php │ │ ├── Runner.php │ │ ├── TileForces.php │ │ └── UnitAcquisition.php │ └── parse │ │ ├── AlternationParse.php │ │ ├── BooleanAndExpression.php │ │ ├── BooleanAndHandler.php │ │ ├── BooleanEqualsExpression.php │ │ ├── BooleanOrExpression.php │ │ ├── BooleanOrHandler.php │ │ ├── CharacterParse.php │ │ ├── CollectionParse.php │ │ ├── Context.php │ │ ├── EqualsHandler.php │ │ ├── Expression.php │ │ ├── Handler.php │ │ ├── LiteralExpression.php │ │ ├── MarkParse.php │ │ ├── OperatorExpression.php │ │ ├── Parser.php │ │ ├── RepetitionParse.php │ │ ├── Scanner.php │ │ ├── SequenceParse.php │ │ ├── StringLiteralHandler.php │ │ ├── StringLiteralParse.php │ │ ├── VariableExpression.php │ │ ├── VariableHandler.php │ │ └── WordParse.php ├── ch12 │ ├── batch01 │ │ ├── AppException.php │ │ ├── ApplicationHelper.php │ │ └── data │ │ │ ├── cmap │ │ │ ├── dsn │ │ │ ├── request │ │ │ ├── woo.db │ │ │ └── woo_options.xml │ ├── batch02 │ │ ├── Registry.php │ │ ├── Request.php │ │ └── Runner.php │ ├── batch03 │ │ ├── Registry.php │ │ ├── Request.php │ │ └── Runner.php │ ├── batch04 │ │ ├── Conf.php │ │ ├── MockRegistry.php │ │ ├── Registry.php │ │ ├── Request.php │ │ ├── Runner.php │ │ └── TreeBuilder.php │ ├── batch05 │ │ ├── AppException.php │ │ ├── ApplicationHelper.php │ │ ├── CliRequest.php │ │ ├── Command.php │ │ ├── CommandResolver.php │ │ ├── Conf.php │ │ ├── Controller.php │ │ ├── DefaultCommand.php │ │ ├── HttpRequest.php │ │ ├── Registry.php │ │ ├── Request.php │ │ ├── Runner.php │ │ ├── TestRequest.php │ │ ├── data │ │ │ └── woo_options.ini │ │ ├── index.php │ │ └── main.php │ ├── batch06 │ │ ├── AddVenue.php │ │ ├── AppController.php │ │ ├── AppException.php │ │ ├── ApplicationHelper.php │ │ ├── CliRequest.php │ │ ├── Command.php │ │ ├── ComponentDescriptor.php │ │ ├── Conf.php │ │ ├── Controller.php │ │ ├── DefaultCommand.php │ │ ├── ForwardViewComponent.php │ │ ├── HttpRequest.php │ │ ├── Registry.php │ │ ├── Request.php │ │ ├── Runner.php │ │ ├── TemplateViewComponent.php │ │ ├── TestRequest.php │ │ ├── ViewComponent.php │ │ ├── ViewComponentCompiler.php │ │ ├── data │ │ │ ├── woo_options.ini │ │ │ └── woo_options.xml │ │ ├── index.php │ │ └── view │ │ │ ├── addspace.php │ │ │ ├── addvenue.php │ │ │ └── main.php │ ├── batch07 │ │ ├── Runner.php │ │ ├── Venue.php │ │ ├── VenueMapper.php │ │ └── venues.php │ ├── batch08 │ │ ├── AddVenueController.php │ │ ├── CliRequest.php │ │ ├── ListVenuesController.php │ │ ├── PageController.php │ │ ├── Runner.php │ │ ├── addvenue.php │ │ ├── listvenues.php │ │ └── view │ │ │ ├── add_venue.php │ │ │ ├── error.php │ │ │ └── list_venues.php │ ├── batch09 │ │ ├── ListVenuesController.php │ │ ├── PageController.php │ │ ├── ViewHelper.php │ │ ├── listvenues.php │ │ └── view │ │ │ └── list_venues.php │ ├── batch10 │ │ ├── Base.php │ │ ├── Runner.php │ │ ├── TableCreator.php │ │ ├── VenueBooker.php │ │ ├── VenueManager.php │ │ └── data │ │ │ ├── woo.db │ │ │ └── woo_options.ini │ └── batch11 │ │ ├── Collection.php │ │ ├── DomainObject.php │ │ ├── Runner.php │ │ ├── Space.php │ │ ├── SpaceCollection.php │ │ └── Venue.php ├── ch13 │ ├── batch01 │ │ ├── Collection.php │ │ ├── DomainObject.php │ │ ├── GenCollection.php │ │ ├── GenVenueCollection.php │ │ ├── Mapper.php │ │ ├── Registry.php │ │ ├── Runner.php │ │ ├── Space.php │ │ ├── SpaceCollection.php │ │ ├── SpaceMapper.php │ │ ├── Venue.php │ │ ├── VenueCollection.php │ │ ├── VenueMapper.php │ │ ├── add.php │ │ └── data │ │ │ ├── woo.db │ │ │ └── woo_options.ini │ ├── batch02 │ │ ├── Runner.php │ │ └── VenueMapper.php │ ├── batch03 │ │ ├── Mapper.php │ │ ├── ObjectWatcher.php │ │ ├── Runner.php │ │ └── VenueMapper.php │ ├── batch04 │ │ ├── Collection.php │ │ ├── DeferredEventCollection.php │ │ ├── DomainObject.php │ │ ├── Event.php │ │ ├── EventCollection.php │ │ ├── EventMapper.php │ │ ├── Mapper.php │ │ ├── ObjectWatcher.php │ │ ├── Registry.php │ │ ├── Runner.php │ │ ├── Space.php │ │ ├── SpaceCollection.php │ │ ├── SpaceMapper.php │ │ ├── Venue.php │ │ ├── VenueCollection.php │ │ └── VenueMapper.php │ ├── batch05 │ │ ├── Collection.php │ │ ├── DeferredEventCollection.php │ │ ├── DomainObjectFactory.php │ │ ├── EventCollection.php │ │ ├── EventMapper.php │ │ ├── EventObjectFactory.php │ │ ├── EventPersistenceFactory.php │ │ ├── Mapper.php │ │ ├── PersistenceFactory.php │ │ ├── Runner.php │ │ ├── SpaceCollection.php │ │ ├── SpaceMapper.php │ │ ├── SpaceObjectFactory.php │ │ ├── SpacePersistenceFactory.php │ │ ├── VenueCollection.php │ │ ├── VenueMapper.php │ │ ├── VenueObjectFactory.php │ │ └── VenuePersistenceFactory.php │ ├── batch06 │ │ ├── EventIdentityObject.php │ │ ├── IdentityObject.php │ │ └── Runner.php │ └── batch07 │ │ ├── DomainObjectAssembler.php │ │ ├── EventIdentityObject.php │ │ ├── EventPersistenceFactory.php │ │ ├── Field.php │ │ ├── IdentityObject.php │ │ ├── PersistenceFactory.php │ │ ├── Runner.php │ │ ├── SelectionFactory.php │ │ ├── SpacePersistenceFactory.php │ │ ├── UpdateFactory.php │ │ ├── VenueIdentityObject.php │ │ ├── VenuePersistenceFactory.php │ │ ├── VenueSelectionFactory.php │ │ └── VenueUpdateFactory.php ├── ch15 │ ├── batch01 │ │ ├── EarthGame.php │ │ ├── EbookParser.php │ │ ├── Game.php │ │ ├── GrowTools.php │ │ ├── Marsh.php │ │ ├── Playable.php │ │ ├── Right.php │ │ ├── Runner.php │ │ ├── Savable.php │ │ ├── TerrainUtil.php │ │ ├── Tree.php │ │ ├── Wrong.php │ │ ├── index.php │ │ └── phpcsBroken.php │ ├── batch02 │ │ ├── Services.php │ │ └── composer.json │ ├── batch03 │ │ ├── composer.json │ │ ├── index.php │ │ └── mylib │ │ │ ├── LibraryCatalogue.php │ │ │ └── inventory │ │ │ └── Book.php │ └── batch04 │ │ ├── additional │ │ └── inventory │ │ │ └── Ebook.php │ │ ├── composer.json │ │ ├── index.php │ │ └── mylib │ │ ├── LibraryCatalogue.php │ │ └── inventory │ │ └── Book.php ├── ch16 │ ├── batch01 │ │ ├── composer.json │ │ ├── composerversion.sh │ │ └── getcomposer.sh │ ├── batch02 │ │ └── composer.json │ ├── batch03 │ │ └── composer.json │ ├── batch05 │ │ └── composer.json │ └── batch06 │ │ └── composer.json ├── ch18 │ ├── batch01 │ │ ├── Runner.php │ │ ├── UserStore.php │ │ ├── UserStoreTest.php │ │ └── Validator.php │ ├── batch02 │ │ ├── UserStore.php │ │ ├── UserStoreTest.php │ │ ├── Validator.php │ │ └── ValidatorTest.php │ ├── batch03 │ │ ├── User.php │ │ ├── UserStore.php │ │ ├── UserStoreTest.php │ │ ├── Validator.php │ │ └── ValidatorTest.php │ └── batch04 │ │ ├── AddVenueTest.php │ │ ├── AddVenueTest2.php │ │ ├── Runner.php │ │ ├── SeleniumTest1.php │ │ ├── SeleniumTest2.php │ │ ├── SeleniumTest3.php │ │ ├── data │ │ ├── cmap │ │ ├── dsn │ │ ├── request │ │ ├── woo.db │ │ └── woo_options.xml │ │ ├── webwoo │ │ ├── AddSpace.php │ │ ├── AddVenue.php │ │ ├── Main.php │ │ └── index.php │ │ └── woo │ │ ├── base │ │ ├── AppException.php │ │ ├── ApplicationRegistry.php │ │ ├── DBException.php │ │ ├── MemApplicationRegistry.php │ │ ├── Registry.php │ │ ├── RequestRegistry.php │ │ ├── Runner.php │ │ └── SessionRegistry.php │ │ ├── command │ │ ├── AddSpace.php │ │ ├── AddVenue.php │ │ ├── Command.php │ │ ├── DefaultCommand.php │ │ ├── DefaultCommand2.php │ │ └── ListVenues.php │ │ ├── controller │ │ ├── AppController.php │ │ ├── ApplicationHelper.php │ │ ├── Controller.php │ │ ├── ControllerMap.php │ │ └── Request.php │ │ ├── domain.php │ │ ├── domain │ │ ├── DomainObject.php │ │ ├── Event.php │ │ ├── EventCollection.php │ │ ├── EventFinder.php │ │ ├── Finder.php │ │ ├── HelperFactory.php │ │ ├── ObjectWatcher.php │ │ ├── Runner.php │ │ ├── Space.php │ │ ├── SpaceCollection.php │ │ ├── SpaceFinder.php │ │ ├── Venue.php │ │ ├── VenueCollection.php │ │ └── VenueFinder.php │ │ ├── mapper │ │ ├── Collection.php │ │ ├── DeferredEventCollection.php │ │ ├── EventCollection.php │ │ ├── EventMapper.php │ │ ├── Mapper.php │ │ ├── Runner.php │ │ ├── SpaceCollection.php │ │ ├── SpaceMapper.php │ │ ├── VenueCollection.php │ │ └── VenueMapper.php │ │ └── view │ │ ├── ViewHelper.php │ │ ├── addspace.php │ │ ├── addvenue.php │ │ ├── listvenues.php │ │ └── main.php ├── ch19 │ ├── build.xml.1 │ ├── build.xml.10 │ ├── build.xml.11 │ ├── build.xml.12 │ ├── build.xml.13 │ ├── build.xml.14 │ ├── build.xml.2 │ ├── build.xml.3 │ ├── build.xml.4 │ ├── build.xml.5 │ ├── build.xml.6 │ ├── build.xml.7 │ ├── build.xml.8 │ ├── build.xml.9 │ ├── build.xml.full │ ├── megaquiz.properties │ └── src │ │ ├── config │ │ └── Config.php │ │ ├── lib │ │ ├── .htaccess │ │ ├── Config.php │ │ ├── command │ │ │ ├── Command.php │ │ │ ├── CommandContext.php │ │ │ ├── FeedbackCommand.php │ │ │ └── LoginCommand.php │ │ ├── quizobjects │ │ │ ├── FinishedTest.php │ │ │ ├── Tree.php │ │ │ ├── TreeTest.php │ │ │ ├── User.php │ │ │ ├── User_test.php │ │ │ └── description.txt │ │ └── quiztools │ │ │ └── AccessManager.php │ │ ├── main.php │ │ └── views │ │ └── index.html ├── ch20 │ ├── infrastructure │ │ ├── Vagrantfile │ │ ├── poppch20.conf │ │ └── setup.sh │ └── webwoo │ │ ├── AddSpace.php │ │ ├── AddVenue.php │ │ ├── Main.php │ │ └── index.php ├── ch21 │ ├── build.xml │ ├── composer.json │ ├── src │ │ ├── domain │ │ │ └── User.php │ │ ├── persist │ │ │ └── UserStore.php │ │ └── util │ │ │ └── Validator.php │ └── test │ │ ├── persist │ │ └── UserStoreTest.php │ │ └── util │ │ └── ValidatorTest.php └── ch24 │ └── batch01 │ ├── AVQuestion.php │ ├── MarkLogicMarker.php │ ├── Marker.php │ ├── MatchMarker.php │ ├── Question.php │ ├── RegexpMarker.php │ ├── Runner.php │ ├── TextQuestion.php │ ├── interpreter │ ├── BooleanAndExpression.php │ ├── BooleanEqualsExpression.php │ ├── BooleanOrExpression.php │ ├── Expression.php │ ├── InterpreterContext.php │ ├── LiteralExpression.php │ ├── OperatorExpression.php │ └── VariableExpression.php │ ├── marklogic │ ├── BooleanAndHandler.php │ ├── BooleanOrHandler.php │ ├── EqualsHandler.php │ ├── MarkParse.php │ ├── StringLiteralHandler.php │ └── VariableHandler.php │ └── parse │ ├── AlternationParse.php │ ├── CharacterParse.php │ ├── CollectionParse.php │ ├── Context.php │ ├── Handler.php │ ├── NotParse.php │ ├── Parser.php │ ├── Reader.php │ ├── RepetitionParse.php │ ├── Scanner.php │ ├── ScannerState.php │ ├── SequenceParse.php │ ├── StringLiteralParse.php │ ├── StringReader.php │ └── WordParse.php └── test ├── BaseUnit.php ├── ch03 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch04_1Test.php ├── Batch04_2Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php ├── Batch08Test.php ├── Batch09Test.php ├── Batch10Test.php ├── Batch11Test.php ├── Batch12Test.php ├── Batch13Test.php ├── Batch14Test.php └── Batch15Test.php ├── ch04 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch06_1Test.php ├── Batch06_2Test.php ├── Batch06_3Test.php ├── Batch06_4Test.php ├── Batch06_5Test.php ├── Batch06_6Test.php ├── Batch06_7Test.php ├── Batch06_8Test.php ├── Batch06_9Test.php ├── Batch07Test.php ├── Batch08Test.php ├── Batch09Test.php ├── Batch10Test.php ├── Batch11Test.php ├── Batch12Test.php ├── Batch13Test.php ├── Batch14Test.php ├── Batch15Test.php ├── Batch16Test.php ├── Batch17Test.php ├── Batch18Test.php ├── Batch19Test.php ├── Batch20Test.php ├── Batch21Test.php ├── Batch22Test.php ├── Batch23Test.php └── Batch24Test.php ├── ch05 ├── Batch01and02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php ├── Batch08Test.php └── Batch09Test.php ├── ch06 ├── Batch01Test.php ├── Batch02Test.php └── Batch03Test.php ├── ch08 ├── Batch01Test.php ├── Batch02Test.php └── Batch03Test.php ├── ch09 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php ├── Batch08Test.php ├── Batch09Test.php ├── Batch10Test.php ├── Batch11Test.php ├── Batch12Test.php ├── Batch13Test.php ├── Batch14Test.php ├── Batch14_1Test.php └── Batch15Test.php ├── ch10 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php └── Batch08Test.php ├── ch11 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php ├── Batch08Test.php ├── Batch09Test.php ├── Batch10Test.php ├── Batch11Test.php └── Batch12Test.php ├── ch12 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php ├── Batch07Test.php ├── Batch08Test.php ├── Batch10Test.php ├── Batch11Test.php ├── TestCommandBatch05.php ├── TestCommandBatch06.php ├── error.php ├── fallback.php └── main.php ├── ch13 ├── Batch01Test.php ├── Batch02Test.php ├── Batch03Test.php ├── Batch04Test.php ├── Batch05Test.php ├── Batch06Test.php └── Batch07Test.php ├── ch15 └── Batch01Test.php ├── ch18 └── Batch01Test.php └── ch24 ├── Batch01Test.php └── res ├── sample1.txt └── sample2.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /9781484267905.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-8-objects-patterns-practice/497aa712ae99e2c96fbc3206242edb06b423f6f6/9781484267905.jpg -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "phpunit/phpunit": "9.*", 4 | "squizlabs/php_codesniffer": "2.*", 5 | "facebook/webdriver" : "*", 6 | "phing/phing": "2.*" 7 | }, 8 | "autoload": { 9 | "psr-4": { 10 | "popp\\": ["src/"], 11 | "popp\\test\\": ["test/"] 12 | } 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /errata.md: -------------------------------------------------------------------------------- 1 | # Errata for *PHP 8 Objects, Patterns and Practice* 2 | 3 | On **page xx** [Summary of error]: 4 | 5 | Details of error here. Highlight key pieces in **bold**. 6 | 7 | *** 8 | 9 | On **page xx** [Summary of error]: 10 | 11 | Details of error here. Highlight key pieces in **bold**. 12 | 13 | *** -------------------------------------------------------------------------------- /src/ch03/batch01/Runner.php: -------------------------------------------------------------------------------- 1 | producerFirstName . " " 17 | . $this->producerMainName; 18 | } 19 | } 20 | /* /listing 03.13 */ 21 | -------------------------------------------------------------------------------- /src/ch03/batch04/Runner.php: -------------------------------------------------------------------------------- 1 | getProducer()}\n"; 19 | /* /listing 03.16 */ 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ch03/batch04_1/Runner.php: -------------------------------------------------------------------------------- 1 | getProducer()}\n"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch03/batch05/Runner.php: -------------------------------------------------------------------------------- 1 | outputAddresses((string)$settings->resolvedomains); 13 | /* /listing 03.24 */ 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch03/batch05/resolve.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/ch03/batch06/Runner.php: -------------------------------------------------------------------------------- 1 | outputAddresses((string)$settings->resolvedomains); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch03/batch06/resolve.xml: -------------------------------------------------------------------------------- 1 | 2 | false 3 | 4 | -------------------------------------------------------------------------------- /src/ch03/batch07/Runner.php: -------------------------------------------------------------------------------- 1 | write($product1); 16 | /* /listing 03.29 */ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch03/batch07/ShopProductWriter.php: -------------------------------------------------------------------------------- 1 | title . ": " 13 | . $shopProduct->getProducer() 14 | . " (" . $shopProduct->price . ")\n"; 15 | print $str; 16 | } 17 | } 18 | /* /listing 03.28 */ 19 | -------------------------------------------------------------------------------- /src/ch03/batch08/Runner.php: -------------------------------------------------------------------------------- 1 | write(new Wrong()); 16 | /* /listing 03.32 */ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch03/batch08/Wrong.php: -------------------------------------------------------------------------------- 1 | 2 | false 3 | 4 | -------------------------------------------------------------------------------- /src/ch03/batch10/Storage.php: -------------------------------------------------------------------------------- 1 | x = "a"; 17 | /* /listing 03.73 */ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch03/batch11/Storage.php: -------------------------------------------------------------------------------- 1 | products as $shopProduct) { 14 | $str .= $shopProduct->getSummaryLine() . "\n"; 15 | } 16 | print $str; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch04/batch05/Bookable.php: -------------------------------------------------------------------------------- 1 | price; 17 | } 18 | } 19 | /* /listing 04.20 */ 20 | -------------------------------------------------------------------------------- /src/ch04/batch05/TimedService.php: -------------------------------------------------------------------------------- 1 | taxrate / 100 ) * $price ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_1/PriceUtilities.php: -------------------------------------------------------------------------------- 1 | taxrate / 100) * $price); 15 | } 16 | 17 | // other utilities 18 | } 19 | -------------------------------------------------------------------------------- /src/ch04/batch06_1/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | 15 | $u = new UtilityService(); 16 | print $u->calculateTax(100) . "\n"; 17 | /* /listing 04.28 */ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch04/batch06_1/Service.php: -------------------------------------------------------------------------------- 1 | taxrate / 100 ) * $price ); 14 | } 15 | 16 | // other utilities 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_2/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | print $p->generateId() . "\n"; 15 | /* /listing 04.31 */ 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_2/Service.php: -------------------------------------------------------------------------------- 1 | taxrate / 100) * $price); 15 | } 16 | 17 | // other utilities 18 | } 19 | -------------------------------------------------------------------------------- /src/ch04/batch06_3/Service.php: -------------------------------------------------------------------------------- 1 | taxrate / 100 ) * $price ); 14 | } 15 | 16 | // other utilities 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_4/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | /* /listing 04.37 */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch04/batch06_4/Service.php: -------------------------------------------------------------------------------- 1 | taxrate / 100 ) * $price ); 14 | } 15 | 16 | // other utilities 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_5/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | print $u->basicTax(100) . "\n"; 15 | /* /listing 04.39 */ 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_5/Service.php: -------------------------------------------------------------------------------- 1 | taxrate / 100) * $price); 14 | } 15 | 16 | // other utilities 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch06_7/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | /* /suspended_listing 04.38 */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch04/batch06_7/Service.php: -------------------------------------------------------------------------------- 1 | getTaxRate() / 100) * $price); 14 | } 15 | 16 | abstract public function getTaxRate(): float; 17 | // other utilities 18 | } 19 | -------------------------------------------------------------------------------- /src/ch04/batch06_8/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax(100) . "\n"; 14 | /* /suspended_listing 04.41 */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch04/batch06_8/Service.php: -------------------------------------------------------------------------------- 1 | getTaxRate() / 100) * $price); 13 | } 14 | abstract public function getTaxRate(): float; 15 | // other utilities 16 | } 17 | -------------------------------------------------------------------------------- /src/ch04/batch06_9/Runner.php: -------------------------------------------------------------------------------- 1 | calculateTax() . "\n"; 14 | /* /listing 04.48 */ 15 | } 16 | 17 | public static function run2() 18 | { 19 | $u = new UtilityService(100); 20 | print $u->getFinalPrice() . "\n"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ch04/batch06_9/Service.php: -------------------------------------------------------------------------------- 1 | name})\n"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch04/batch08/Product.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | $this->price = $price; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch08/Totalizer.php: -------------------------------------------------------------------------------- 1 | price > 5) { 14 | print " reached high price: {$product->price}\n"; 15 | } 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch04/batch09/conf01.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | localhost 5 | newpass 6 | 7 | -------------------------------------------------------------------------------- /src/ch04/batch10/conf01.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | localhost 5 | newpass 6 | 7 | -------------------------------------------------------------------------------- /src/ch04/batch11/ConfException.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | 7 | -------------------------------------------------------------------------------- /src/ch04/batch11/conf01.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | newpass 7 | 8 | -------------------------------------------------------------------------------- /src/ch04/batch11/log.txt: -------------------------------------------------------------------------------- 1 | start 2 | file exception 3 | end 4 | start 5 | xml exception 6 | -------------------------------------------------------------------------------- /src/ch04/batch12/ConfException.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | bob 4 | newpass 5 | localhost 6 | 7 | -------------------------------------------------------------------------------- /src/ch04/batch13/Checkout.php: -------------------------------------------------------------------------------- 1 | getName() . "\n"; 14 | } 15 | 16 | public function writeAge(Person $p): void 17 | { 18 | print $p->getAge() . "\n"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch04/batch18/Runner.php: -------------------------------------------------------------------------------- 1 | writeName(); 14 | /* /listing 04.90 */ 15 | $person->writeAge(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch04/batch19/CopyMe.php: -------------------------------------------------------------------------------- 1 | setId(343); 16 | $person2 = clone $person; 17 | /* /listing 04.100 */ 18 | return [$person, $person2]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch04/batch21/Account.php: -------------------------------------------------------------------------------- 1 | write($this); 13 | } 14 | 15 | public function getName(): string 16 | { 17 | return "Bob"; 18 | } 19 | 20 | public function getAge(): int 21 | { 22 | return 44; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ch04/batch24/PersonWriter.php: -------------------------------------------------------------------------------- 1 | wave(); 15 | -------------------------------------------------------------------------------- /src/ch05/batch04/Autoload2.php: -------------------------------------------------------------------------------- 1 | wave(); 17 | -------------------------------------------------------------------------------- /src/ch05/batch04/Autoload3.php: -------------------------------------------------------------------------------- 1 | wave(); 16 | -------------------------------------------------------------------------------- /src/ch05/batch04/Autoload3_1.php: -------------------------------------------------------------------------------- 1 | wave(); 17 | -------------------------------------------------------------------------------- /src/ch05/batch04/Blah.php: -------------------------------------------------------------------------------- 1 | thing(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch05/batch07/OtherShop.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | } 16 | } 17 | /* /listing 05.76 */ 18 | -------------------------------------------------------------------------------- /src/ch05/batch08/PersonModule.php: -------------------------------------------------------------------------------- 1 | name}\n"; 13 | } 14 | 15 | public function execute(): void 16 | { 17 | // do things 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch05/batch08/Runner.php: -------------------------------------------------------------------------------- 1 | init(); 14 | /* /listing 05.82 */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch05/batch09/ApiInfo.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | key1 4 | val1 5 | 6 | 7 | key2 8 | val2 9 | 10 | 11 | key3 12 | val3 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/ch06/batch03/newparams.txt: -------------------------------------------------------------------------------- 1 | key1:val1 2 | key2:val2 3 | key3:val3 4 | newkey1:newval1 5 | -------------------------------------------------------------------------------- /src/ch06/batch03/params.txt: -------------------------------------------------------------------------------- 1 | key1:val1 2 | key2:val2 3 | key3:val3 4 | -------------------------------------------------------------------------------- /src/ch06/batch03/params.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | key1 4 | val1 5 | 6 | 7 | key2 8 | val2 9 | 10 | 11 | key3 12 | val3 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/ch08/batch01/Lecture.php: -------------------------------------------------------------------------------- 1 | inform("new lesson: cost ({$lesson->cost()})"); 17 | } 18 | } 19 | /* /listing 08.13 */ 20 | -------------------------------------------------------------------------------- /src/ch08/batch02/Seminar.php: -------------------------------------------------------------------------------- 1 | getDuration() * 5); 13 | } 14 | 15 | public function chargeType(): string 16 | { 17 | return "hourly rate"; 18 | } 19 | } 20 | /* /listing 08.10 */ 21 | -------------------------------------------------------------------------------- /src/ch09/batch01/Employee.php: -------------------------------------------------------------------------------- 1 | name}: I'll clear my desk\n"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch09/batch01/Runner.php: -------------------------------------------------------------------------------- 1 | addEmployee("harry"); 14 | $boss->addEmployee("bob"); 15 | $boss->addEmployee("mary"); 16 | $boss->projectFails(); 17 | /* /listing 09.04 */ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch09/batch02/CluedUp.php: -------------------------------------------------------------------------------- 1 | name}: I'll call my lawyer\n"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch09/batch02/Employee.php: -------------------------------------------------------------------------------- 1 | name}: I'll clear my desk\n"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch09/batch03/CluedUp.php: -------------------------------------------------------------------------------- 1 | name}: I'll call my lawyer\n"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch09/batch03/Minion.php: -------------------------------------------------------------------------------- 1 | name}: I'll clear my desk\n"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch09/batch03/WellConnected.php: -------------------------------------------------------------------------------- 1 | name}: I'll call my dad\n"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch09/batch05/PreferencesImpl.php: -------------------------------------------------------------------------------- 1 | getDsn(); 14 | 15 | Preferences::mockmode(); 16 | $pref = Preferences::getInstance(); 17 | 18 | print $pref->getDsn(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/ch09/batch06/ApptEncoder.php: -------------------------------------------------------------------------------- 1 | getApptEncoder(); 13 | $out = $encoder->encode(); 14 | print "{$out}\n"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch09/batch07/ApptEncoder.php: -------------------------------------------------------------------------------- 1 | getHeaderText(); 14 | print $mgr->getApptEncoder()->encode(); 15 | print $mgr->getFooterText(); 16 | /* /listing 09.26 */ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch09/batch09/ApptEncoder.php: -------------------------------------------------------------------------------- 1 | getHeaderText(); 13 | print $mgr->getApptEncoder()->encode(); 14 | print $mgr->getFooterText(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch09/batch10/ApptEncoder.php: -------------------------------------------------------------------------------- 1 | getHeaderText(); 13 | print $mgr->make(CommsManager::APPT)->encode(); 14 | print $mgr->getFooterText(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch09/batch11/EarthForest.php: -------------------------------------------------------------------------------- 1 | getCommsManager(); 12 | print $commsMgr->getApptEncoder()->encode(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch09/batch13/Settings.php: -------------------------------------------------------------------------------- 1 | encode(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch09/batch14/AppointmentMaker2.php: -------------------------------------------------------------------------------- 1 | encoder->encode(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ch09/batch14/Runner.php: -------------------------------------------------------------------------------- 1 | getComponent(AppointmentMaker2::class); 14 | $out = $apptmaker->makeAppointment(); 15 | print $out; 16 | /* /listing 09.61 */ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch09/batch14_1/AppointmentMaker.php: -------------------------------------------------------------------------------- 1 | encode(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch09/batch14_1/AppointmentMaker2.php: -------------------------------------------------------------------------------- 1 | encoder->encode(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch09/batch14_1/objects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/ch09/batch15/AppointmentMaker2.php: -------------------------------------------------------------------------------- 1 | encoder->encode(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch09/batch15/Inject.php: -------------------------------------------------------------------------------- 1 | addUnit($unit1); 14 | $army->addUnit($unit2); 15 | print $army->bombardStrength(); 16 | /* /listing 10.03 */ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch10/batch01/Unit.php: -------------------------------------------------------------------------------- 1 | getUnits() as $unit) { 14 | $ret += $unit->bombardStrength(); 15 | } 16 | return $ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch10/batch05/Cavalry.php: -------------------------------------------------------------------------------- 1 | tile->getWealthFactor() + 2; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch10/batch06/DiamondPlains.php: -------------------------------------------------------------------------------- 1 | wealthfactor; 16 | } 17 | } 18 | /* /listing 10.18 */ 19 | /* /listing 10.23 */ 20 | -------------------------------------------------------------------------------- /src/ch10/batch06/PollutedPlains.php: -------------------------------------------------------------------------------- 1 | tile->getWealthFactor() - 4; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch10/batch06/Tile.php: -------------------------------------------------------------------------------- 1 | tile = $tile; 15 | } 16 | } 17 | /* /listing 10.24 */ 18 | -------------------------------------------------------------------------------- /src/ch10/batch07/AuthenticateRequest.php: -------------------------------------------------------------------------------- 1 | processrequest->process($req); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch10/batch07/DecorateProcess.php: -------------------------------------------------------------------------------- 1 | processrequest->process($req); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch10/batch07/MainProcess.php: -------------------------------------------------------------------------------- 1 | processrequest->process($req); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch10/batch08/test.txt: -------------------------------------------------------------------------------- 1 | xx 2 | -------------------------------------------------------------------------------- /src/ch10/batch08/test2.txt: -------------------------------------------------------------------------------- 1 | 234-ladies_jumper 55 2 | 532-gents_hat 44 3 | -------------------------------------------------------------------------------- /src/ch11/batch01/BooleanAndExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l && $result_r); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch11/batch01/BooleanEqualsExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l == $result_r); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch11/batch01/BooleanOrExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l || $result_r); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch11/batch01/LiteralExpression.php: -------------------------------------------------------------------------------- 1 | value = $value; 15 | } 16 | 17 | public function interpret(InterpreterContext $context): void 18 | { 19 | $context->replace($this, $this->value); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ch11/batch02/AVQuestion.php: -------------------------------------------------------------------------------- 1 | test == $response); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch11/batch02/Question.php: -------------------------------------------------------------------------------- 1 | marker->mark($response); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch11/batch02/RegexpMarker.php: -------------------------------------------------------------------------------- 1 | test", $response) === 1); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch11/batch02/TextQuestion.php: -------------------------------------------------------------------------------- 1 | handleLogin("bob", "mypass", '158.152.55.35'); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/batch04/Logger.php: -------------------------------------------------------------------------------- 1 | handleLogin("bob", "mypass", '158.152.55.35'); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/batch05/GeneralLogger.php: -------------------------------------------------------------------------------- 1 | getStatus(); 13 | // add login data to log 14 | print __CLASS__ . ": add login data to log\n"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/batch05/LoginAnalytics.php: -------------------------------------------------------------------------------- 1 | getStatus(); 14 | print __CLASS__ . ": doing something with status info\n"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/batch05/Observable.php: -------------------------------------------------------------------------------- 1 | getStatus(); 13 | // check $ip address 14 | // set cookie if it matches a list 15 | print __CLASS__ . ": set cookie if it matches a list\n"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch11/batch05/SecurityMonitor.php: -------------------------------------------------------------------------------- 1 | getStatus(); 13 | if ($status[0] == Login::LOGIN_WRONG_PASS) { 14 | // send mail to sysadmin 15 | print __CLASS__ . ": sending mail to sysadmin\n"; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch11/batch06/GeneralLogger.php: -------------------------------------------------------------------------------- 1 | getStatus(); 12 | // add login data to log 13 | print __CLASS__ . ":\tadd login data to log\n"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch11/batch06/PartnershipTool.php: -------------------------------------------------------------------------------- 1 | getStatus(); 12 | // check $ip address 13 | // set cookie if it matches a list 14 | print __CLASS__ . ":\tset cookie if it matches a list\n"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/batch06/SecurityMonitor.php: -------------------------------------------------------------------------------- 1 | getStatus(); 12 | if ($status[0] == Login::LOGIN_WRONG_PASS) { 13 | // send mail to sysadmin 14 | print __CLASS__ . ":\tsending mail to sysadmin\n"; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch11/batch07/Archer.php: -------------------------------------------------------------------------------- 1 | units() as $unit) { 15 | $strength += $unit->bombardStrength(); 16 | } 17 | 18 | return $strength; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch11/batch07/Cavalry.php: -------------------------------------------------------------------------------- 1 | units() as $unit) { 14 | $strength += $unit->bombardStrength(); 15 | } 16 | return $strength; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch11/batch08/Cavalry.php: -------------------------------------------------------------------------------- 1 | firepower(); 15 | 16 | print "power is {$power}\n"; 17 | /* /listing 11.58 */ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch11/batch12/Runner.php: -------------------------------------------------------------------------------- 1 | isNull()) { 16 | // do something 17 | } else { 18 | print "null - no action\n"; 19 | } 20 | /* /listing 11.63 */ 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ch11/parse/BooleanAndExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l && $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/parse/BooleanAndHandler.php: -------------------------------------------------------------------------------- 1 | popResult(); 12 | $comp2 = $scanner->popResult(); 13 | $scanner->pushResult(new BooleanAndExpression($comp1, $comp2)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch11/parse/BooleanEqualsExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l == $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/parse/BooleanOrExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l || $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch11/parse/BooleanOrHandler.php: -------------------------------------------------------------------------------- 1 | popResult(); 12 | $comp2 = $scanner->popResult(); 13 | $scanner->pushResult(new BooleanOrExpression($comp1, $comp2)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch11/parse/Context.php: -------------------------------------------------------------------------------- 1 | expressionstore[$exp->getKey()] = $value; 13 | } 14 | 15 | public function lookup(Expression $exp) 16 | { 17 | return $this->expressionstore[$exp->getKey()]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch11/parse/EqualsHandler.php: -------------------------------------------------------------------------------- 1 | popResult(); 12 | $comp2 = $scanner->popResult(); 13 | $scanner->pushResult(new BooleanEqualsExpression($comp1, $comp2)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch11/parse/Expression.php: -------------------------------------------------------------------------------- 1 | key)) { 16 | self::$keycount++; 17 | $this->key = self::$keycount; 18 | } 19 | return $this->key; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ch11/parse/Handler.php: -------------------------------------------------------------------------------- 1 | value = $value; 14 | } 15 | 16 | public function interpret(Context $context) 17 | { 18 | $context->replace($this, $this->value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch11/parse/StringLiteralHandler.php: -------------------------------------------------------------------------------- 1 | popResult(); 12 | $scanner->pushResult(new LiteralExpression($value)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch11/parse/VariableHandler.php: -------------------------------------------------------------------------------- 1 | popResult(); 12 | $scanner->pushResult(new VariableExpression($varname)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch12/batch01/AppException.php: -------------------------------------------------------------------------------- 1 | getRequest()); 14 | /* /listing 12.04 */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch12/batch03/Request.php: -------------------------------------------------------------------------------- 1 | set('request', new Request()); 14 | 15 | $reg = Registry::instance(); 16 | print_r($reg->get('request')); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch12/batch04/Conf.php: -------------------------------------------------------------------------------- 1 | doExecute($request); 17 | } 18 | 19 | abstract protected function doExecute(Request $request): void; 20 | } 21 | /* /listing 12.14 */ 22 | -------------------------------------------------------------------------------- /src/ch12/batch05/DefaultCommand.php: -------------------------------------------------------------------------------- 1 | addFeedback("Welcome to WOO"); 13 | include(__DIR__ . "/main.php"); 14 | } 15 | } 16 | /* /listing 12.18 */ 17 | -------------------------------------------------------------------------------- /src/ch12/batch05/Runner.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ch12/batch06/AppException.php: -------------------------------------------------------------------------------- 1 | addFeedback("Welcome to WOO"); 12 | return Command::CMD_DEFAULT; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch12/batch06/ForwardViewComponent.php: -------------------------------------------------------------------------------- 1 | forward($this->path); 17 | } 18 | } 19 | /* /listing 12.28 */ 20 | -------------------------------------------------------------------------------- /src/ch12/batch06/Runner.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Add a Venue 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 |
10 | getFeedbackString("
"); ?> 11 |
14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ch12/batch06/view/main.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | Woo! it's WOO! 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 |
15 | getFeedbackString("
"); ?> 16 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ch12/batch07/Runner.php: -------------------------------------------------------------------------------- 1 | name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ch12/batch07/VenueMapper.php: -------------------------------------------------------------------------------- 1 | fakevenues as $venuename) { 18 | $ret[] = new Venue($venuename); 19 | } 20 | 21 | return $ret; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ch12/batch08/addvenue.php: -------------------------------------------------------------------------------- 1 | init(); 10 | $addvenue->process(); 11 | /* /listing 12.37 */ 12 | -------------------------------------------------------------------------------- /src/ch12/batch08/listvenues.php: -------------------------------------------------------------------------------- 1 | init(); 9 | $addvenue->process(); 10 | -------------------------------------------------------------------------------- /src/ch12/batch08/view/error.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Error 4 | 5 | 6 |

Error

7 | 8 | 9 | 10 | 15 | 16 |
11 | getFeedbackString("
"); 13 | ?> 14 |
17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/ch12/batch08/view/list_venues.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Venues 4 | 5 | 6 |

Venues

7 | 8 | Listing venues 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/ch12/batch09/ListVenuesController.php: -------------------------------------------------------------------------------- 1 | getRequest(); 12 | $this->render(__DIR__ . '/view/list_venues.php', $request); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch12/batch09/ViewHelper.php: -------------------------------------------------------------------------------- 1 | init(); 9 | $addvenue->process(); 10 | -------------------------------------------------------------------------------- /src/ch12/batch09/view/list_venues.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Venues 5 | 6 | 7 |

Venues

8 | 9 |
10 | Proudly sponsored by: sponsorList(); ?> 11 | 12 |
13 | 14 | Listing venues 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/ch12/batch10/VenueBooker.php: -------------------------------------------------------------------------------- 1 | vals[] = $space; 14 | } 15 | 16 | // dummy implementation 17 | public static function getCollection($type): SpaceCollection 18 | { 19 | return new SpaceCollection(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ch12/batch11/Runner.php: -------------------------------------------------------------------------------- 1 | addSpace(new Space(-1, "the big stage")); 14 | $spaces = $venue->getSpaces(); 15 | $venue->setSpaces($spaces); 16 | return $venue; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ch12/batch11/SpaceCollection.php: -------------------------------------------------------------------------------- 1 | add(new \woo\domain\Venue(null, "Loud and Thumping")); 8 | $collection->add(new \woo\domain\Venue(null, "Eeezy")); 9 | $collection->add(new \woo\domain\Venue(null, "Duck and Badger")); 10 | 11 | foreach ($collection as $venue) { 12 | print $venue->getName() . "\n"; 13 | } 14 | -------------------------------------------------------------------------------- /src/ch13/batch01/data/woo.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/php-8-objects-patterns-practice/497aa712ae99e2c96fbc3206242edb06b423f6f6/src/ch13/batch01/data/woo.db -------------------------------------------------------------------------------- /src/ch13/batch01/data/woo_options.ini: -------------------------------------------------------------------------------- 1 | [config] 2 | dsn=sqlite:/var/popp/src/ch13/batch01/data/woo.db 3 | templatepath=/var/popp/src/ch13/batch01/ 4 | 5 | -------------------------------------------------------------------------------- /src/ch13/batch04/EventCollection.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | } 16 | 17 | public function getName(): ?string 18 | { 19 | return $this->name; 20 | } 21 | } 22 | /* /listing 13.37 */ 23 | -------------------------------------------------------------------------------- /src/ch13/batch07/EventIdentityObject.php: -------------------------------------------------------------------------------- 1 | 1) { 13 | $this->setFormat(1); 14 | } 15 | } 16 | 17 | private function setformat(int $format): void 18 | { 19 | // do something with $format 20 | } 21 | } 22 | /* /listing 15.17 */ 23 | -------------------------------------------------------------------------------- /src/ch15/batch01/Game.php: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /src/ch15/batch01/Savable.php: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /src/ch15/batch01/index.php: -------------------------------------------------------------------------------- 1 | 1) 10 | $this->setFormat( 1 ); 11 | } 12 | 13 | function setformat(int $format) { 14 | // do something with $format 15 | } 16 | } 17 | /* /listing 15.16 */ 18 | -------------------------------------------------------------------------------- /src/ch15/batch02/Services.php: -------------------------------------------------------------------------------- 1 | addBook(new Ebook()); 9 | $catalogue->addBook(new Book()); 10 | -------------------------------------------------------------------------------- /src/ch15/batch03/mylib/LibraryCatalogue.php: -------------------------------------------------------------------------------- 1 | books[] = $book; 17 | } 18 | } 19 | /* /listing 15.19 */ 20 | -------------------------------------------------------------------------------- /src/ch15/batch03/mylib/inventory/Book.php: -------------------------------------------------------------------------------- 1 | addBook(new Book()); 15 | $catalogue->addBook(new Ebook()); 16 | /* /listing 15.22 */ 17 | -------------------------------------------------------------------------------- /src/ch15/batch04/mylib/LibraryCatalogue.php: -------------------------------------------------------------------------------- 1 | books[] = $book; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ch15/batch04/mylib/inventory/Book.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Woo! it's WOO! 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 |
10 | Welcome to WOO
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ch18/batch04/webwoo/index.php: -------------------------------------------------------------------------------- 1 | addFeedback("Welcome to WOO"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/command/DefaultCommand2.php: -------------------------------------------------------------------------------- 1 | addFeedback("Welcome to WOO"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/command/ListVenues.php: -------------------------------------------------------------------------------- 1 | setObject('venues', $collection); 14 | return self::statuses('CMD_OK'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/domain.php: -------------------------------------------------------------------------------- 1 | package}\\Event"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/mapper/Runner.php: -------------------------------------------------------------------------------- 1 | package}\\Space"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/mapper/VenueCollection.php: -------------------------------------------------------------------------------- 1 | package}\\Venue"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch18/batch04/woo/view/ViewHelper.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | Woo! it's WOO! 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 |
17 | getFeedbackString("
"); ?> 18 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/ch19/build.xml.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/ch19/build.xml.11: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | pass: ${dbpass} 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/ch19/build.xml.2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/ch19/build.xml.7: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | pass: ${dbpass} 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/ch19/build.xml.8: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | name: ${phing.project.name} 10 | base: ${project.basedir} 11 | home: ${user.home} 12 | pass: ${env.DBPASS} 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/ch19/build.xml.9: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | database: ${dbname} 10 | pass: ${dbpass} 11 | host: ${dbhost} 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/ch19/megaquiz.properties: -------------------------------------------------------------------------------- 1 | dbname=filedb 2 | dbpass=filepass 3 | dbhost=filehost 4 | -------------------------------------------------------------------------------- /src/ch19/src/config/Config.php: -------------------------------------------------------------------------------- 1 | >>>>>> 1.2 12 | class User 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /src/ch19/src/lib/quizobjects/User_test.php: -------------------------------------------------------------------------------- 1 | kksj 2 | -------------------------------------------------------------------------------- /src/ch19/src/lib/quizobjects/description.txt: -------------------------------------------------------------------------------- 1 | jijkj 2 | -------------------------------------------------------------------------------- /src/ch19/src/main.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/ch20/infrastructure/poppch20.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin matt@getinstance.com 3 | DocumentRoot /var/www/poppch20 4 | ServerName poppch20.vagrant.internal 5 | ErrorLog logs/poppch20-error_log 6 | CustomLog logs/poppch20-access_log common 7 | 8 | 9 | 10 | AllowOverride all 11 | 12 | -------------------------------------------------------------------------------- /src/ch20/webwoo/Main.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Woo! it's WOO! 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 |
10 | Welcome to WOO
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ch20/webwoo/index.php: -------------------------------------------------------------------------------- 1 | test = $test; 14 | } 15 | 16 | abstract public function mark(string $response): bool; 17 | } 18 | -------------------------------------------------------------------------------- /src/ch24/batch01/MatchMarker.php: -------------------------------------------------------------------------------- 1 | test == $response ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ch24/batch01/RegexpMarker.php: -------------------------------------------------------------------------------- 1 | test}", $response); 12 | return ( ! is_bool($match) && $match > 0 ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/ch24/batch01/TextQuestion.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l && $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch24/batch01/interpreter/BooleanEqualsExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l == $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch24/batch01/interpreter/BooleanOrExpression.php: -------------------------------------------------------------------------------- 1 | replace($this, $result_l || $result_r); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ch24/batch01/interpreter/LiteralExpression.php: -------------------------------------------------------------------------------- 1 | value = $value; 14 | } 15 | 16 | public function interpret(InterpreterContext $context): void 17 | { 18 | $context->replace($this, $this->value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ch24/batch01/parse/Handler.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertEquals("20\n20\n", $val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ch04/Batch06_2Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertMatchesRegularExpression("/20\n[a-f0-9]+\n/", $val); 17 | //print $val; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ch04/Batch06_4Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 17 | self::assertEquals("222\n", $val); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch04/Batch06_5Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 17 | self::assertEquals("222\n20\n", $val); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch04/Batch06_6Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 17 | self::assertEquals("20\n", $val); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch04/Batch06_7Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 17 | self::assertEquals("20\n", $val); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch04/Batch06_8Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 17 | self::assertEquals("20\n", $val); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ch04/Batch12Test.php: -------------------------------------------------------------------------------- 1 | totalize(); 18 | self::assertTrue($checkout instanceof Checkout); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ch04/Batch17Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run2(); }); 16 | self::assertEquals("BOB", $val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ch05/Batch06Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertEquals("thing\n", $val); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch09/Batch01Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertEquals($val, "mary: I'll clear my desk\n"); 17 | //print $val; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ch09/Batch04Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | //print $val; 17 | $testout = "matt\n"; 18 | self::assertEquals($val, $testout); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/ch09/Batch13Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertEquals("Appointment data encoded in MegaCal format\n", $val); 17 | //print $val; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ch11/Batch03Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertMatchesRegularExpression("/returning (true|false)/", $val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ch12/Batch01Test.php: -------------------------------------------------------------------------------- 1 | getOptions(); 17 | self::assertEquals("sqlite:./data/woo.db", $options[0]); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/ch12/Batch03Test.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertMatchesRegularExpression("/Request/", $val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ch12/TestCommandBatch05.php: -------------------------------------------------------------------------------- 1 | capture(function() { Runner::run(); }); 16 | self::assertMatchesRegularExpression("/^ WHERE name = 'A Fine Show' and start > \d+/", $val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ch24/res/sample1.txt: -------------------------------------------------------------------------------- 1 | this 2 | is a sample 3 | 4 | another test 5 | -------------------------------------------------------------------------------- /test/ch24/res/sample2.txt: -------------------------------------------------------------------------------- 1 | one 2 | 3 | two 4 | 5 | 6 | kjkj 7 | kjkj 8 | kjk 9 | --------------------------------------------------------------------------------