<?php

interface PandaInterface 
{
    public function eat();
    public function poop();
    public function sleep();
}

class RedPanda implements PandaInterface 
{
    public function eat() 
    {
        echo "The red panda eats some fruit.\n";
    }
    
    public function poop() 
    {
        echo "The red panda takes a poop.\n";
    }
    
    public function sleep() 
    {
        echo "The red panda sleeps up a tree.\n";
    }
}

class GiantPanda implements PandaInterface 
{
    public function eat() 
    {
        echo "The giant panda eats some bamboo.\n";
    }
    
    public function poop() 
    {
        echo "The giant panda takes a giant poop.\n";
    }
    
    public function sleep() 
    {
        echo "The giant panda sleeps on the ground.\n";
    }
}

class ZooKeeper 
{
    /**
     * Care for a panda. Any class that 
     * implements the PandaInterface interface, 
     * can be passed as a parameter to the care() method
     *
     * @param  PandaInterface $panda
     * @return void
     */
    public function care(PandaInterface $panda) 
    {
        $panda->eat();
        $panda->poop();
        $panda->sleep();
    }
}

// Create panda instances.
$redPanda   = new RedPanda;
$giantPanda = new GiantPanda;

// Create the zookeeper.
$keeper = new ZooKeeper;

// Care for both pandas.
$keeper->care($redPanda);
$keeper->care($giantPanda);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: