One class implements several interfaces and takes responsibility to define all methods from both interfaces.
Also defines several private methods additionally
interface int1 {
// Force Extending class to define these methods
function getArea();
}
interface int2 {
function getPerimeter();
}
class Circle implements int1, int2 {
static $PI = 3.1415926536;
public $radius;
public function __construct($radius) {
$this->radius = $radius;
}
public function getPI() {
return self::$PI;
}
public function getArea() {
return pow($this->radius, 2) * self::$PI;
}
public function getDiameter() {
return $this->radius * 2;
}
public function getPerimeter() {
return $this->radius * 2 * self::$PI;
}
}
$circle1 = new Circle(5);
echo "\nPI: " . $circle1->getPI();
echo "\nArea: " . $circle1->getArea();
echo "\nDiameter: " . $circle1->getDiameter();
echo "\nPerimeter: " . $circle1->getPerimeter();