mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 04:00:18 +02:00
improved Flyweight
This commit is contained in:
21
Structural/Flyweight/Word.php
Normal file
21
Structural/Flyweight/Word.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Structural\Flyweight;
|
||||
|
||||
class Word implements Text
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function render(string $font): string
|
||||
{
|
||||
return sprintf('Word %s with font %s', $this->name, $font);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user