interface NamedInterface {
public function name(): string;
}
class WidgetNamedRaw implements NamedRawInterface {
private $name;
private $width;
public function __construct(string $name, int $width) {
$this->name = $name;
$this->width = $width;
}
public function name(): string {
return $this->name;
}
public function setWidth(int $arg) {
$this->width = $arg;
}
}
class WidgetNamed implements NamedInterface {
private $namedRaw;
public function __construct(WidgetNamedRaw $namedRaw) {
$this->widgetNamedRaw = $WidgetNamedRaw;
}
public function name(): string {
return $this->namedRaw()->name;
}
}
class FactoryClass {
public function generate(): NamedInterface {
$widget = new WidgetClass('top', 42);
return $widget;
}
}