hi i have read PHP pro patterns and desing book.
and i read this chapter but i didnt understand.
abstract class DomainObject {
private $group;
public function __construct() {
$this->group = static::getGroup();
}
public static function create() {
return new static();
}
static function getGroup() {
return "default";
}
}
class User extends DomainObject {
}
class Document extends DomainObject {
static function getGroup() {
return "document";
}
}
class SpreadSheet extends Document {
}
this code outputs
print_r(User::create());
print_r(SpreadSheet::create());
i dont know for what reason
public static function create() {
return new static();
}
used
what is new static();
Thank you very much for attention