<?php

interface DeviceInterface { 
    public function setSender(MessagingInterface $sender);
 
    public function send($body);
}
 
abstract class Device implements DeviceInterface {
    protected $sender;
 
    public function setSender(MessagingInterface $sender) {
        $this->sender = $sender;
    }
}
 
class Phone extends Device {
    public function send($body) {
        $body .= "\n\n Sent from a phone.";
 
        return $this->sender->send($body);
    }
}
 
class Tablet extends Device {
    public function send($body) {
        $body .= "\n\n Sent from a Tablet.";
 
        return $this->sender->send($body);
    }
}
 
interface MessagingInterface { 
    public function send($body);
}
 
class Skype implements MessagingInterface {
    public function send($body) {
        // Send a message through the Skype API
    }
}
 
class Whatsapp implements MessagingInterface {
    public function send($body) {
        // Send a message through the Whatsapp API
    }
}
 
$phone = new Phone;
$phone->setSender(new Skype);
 
$phone->send("Hey Buddy");