<?php
//适配器模式
interface PerfectMan
{
public function do_php();
public function cook();
}
class Wife
{
function cook()
{
echo "做美味的饭菜\n";
}
}
class Me implements PerfectMan
{
private $wife;
public function __construct($wife)
{
$this->wife = $wife;
}
public function do_php()
{
echo "the best love of a man\n";
}
public function cook()
{
$this->wife->cook();
}
}
$wife = new Wife();
$me = new Me($wife);
$me->do_php();
$me->cook();