<?php
interface
Shape {
public
function
draw();
}
interface
Radius {
public
function
setRadius();
}
interface
Main {
public
function
process();
}
class
Circle
implements
Shape, Radius, Main {
public
function
draw(){
echo
"Drawing Circle..."
;
echo
"<br>"
;
}
public
function
setRadius() {
echo
"Setting Radius..."
;
}
public
function
process() {
$this
->setRadius();
$this
->draw();
}
}
class
Square
implements
Shape, Main {
public
function
draw(){
echo
"Drawing Square..."
;
echo
"<br>"
;
}
public
function
process() {
$this
->draw();
}
}
class
Rectangle
implements
Shape, Main {
public
function
draw(){
echo
"Drawing Rectangle..."
;
echo
"<br>"
;
}
public
function
process() {
$this
->draw();
}
}
class
DrawShape {
public
function
newShape(Main
$shape
) {
return
$shape
->process();
}
}
$shapeCircle
=
new
Circle();
$drawCircle
=
new
DrawShape();
$drawCircle
->newShape(
$shapeCircle
);
$shapeSquare
=
new
Square();
$drawSquare
=
new
DrawShape();
$drawSquare
->newShape(
$shapeSquare
);
$shapeRectangle
=
new
Rectangle();
$drawSquare
=
new
DrawShape();
$drawSquare
->newShape(
$shapeRectangle
);
?>