mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 12:10:10 +02:00
Final public method for abstract class
All public methods of abstract classes should be final. Enforce API encapsulation in an inheritance architecture. If you want to override a method, use the Template method pattern.
This commit is contained in:
@@ -22,7 +22,7 @@ abstract class Registry
|
||||
self::LOGGER,
|
||||
];
|
||||
|
||||
public static function set(string $key, Service $value)
|
||||
final public static function set(string $key, Service $value)
|
||||
{
|
||||
if (!in_array($key, self::$allowedKeys)) {
|
||||
throw new InvalidArgumentException('Invalid key given');
|
||||
@@ -31,7 +31,7 @@ abstract class Registry
|
||||
self::$services[$key] = $value;
|
||||
}
|
||||
|
||||
public static function get(string $key): Service
|
||||
final public static function get(string $key): Service
|
||||
{
|
||||
if (!in_array($key, self::$allowedKeys) || !isset(self::$services[$key])) {
|
||||
throw new InvalidArgumentException('Invalid key given');
|
||||
|
Reference in New Issue
Block a user