Enforce Functionality with Abstract Methods

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:04
    Since everything seems to be working on our site,
  • 0:07
    let's start a battle.
  • 0:09
    Four Jedi Starfighters
  • 0:11
    against three Super Star Destroyers.
  • 0:14
  • 0:16
    Ah! An error.
  • 0:18
    "Argument 1 passed to BattleManager::battle
  • 0:22
    "must be an Instance of Ship,
  • 0:24
    Instance of RebelShip given."
  • 0:26
    And this is apparently happening on battle line 32
Loading ...

Enforce Functionality with Abstract Methods


In this tutorial, I will show you the power of abstract classes and how you can enforce subclasses to define certain functions. In this way, you can share logic but for things that are really specific to subclasses, you can force them to define certain functions, but with the specific logic required.

Log in or sign up to download companion files.
Additional resources: