Is it possible in PHP, that an abstract class accesses a constant of the class below?
For example, can I factorize getName in Generic ?
abstract class Generic {
abstract public function getName(): string;
}
class MorePreciseA extends Generic {
private const NAME = "More Precise A";
public function getName(): string {
return self::NAME;
}
}
class MorePreciseB extends Generic {
private const NAME = "More Precise B";
public function getName(): string {
return self::NAME;
}
}
Thanks