mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-09 17:36:22 +02:00
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.
20 lines
350 B
PHP
20 lines
350 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Structural\Bridge;
|
|
|
|
abstract class Service
|
|
{
|
|
public function __construct(protected Formatter $implementation)
|
|
{
|
|
}
|
|
|
|
final public function setImplementation(Formatter $printer)
|
|
{
|
|
$this->implementation = $printer;
|
|
}
|
|
|
|
abstract public function get(): string;
|
|
}
|