mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-10-04 18:21:52 +02:00
update deps & install rector
This commit is contained in:
@@ -11,10 +11,8 @@ class Character implements Text
|
||||
/**
|
||||
* Any state stored by the concrete flyweight must be independent of its context.
|
||||
* For flyweights representing characters, this is usually the corresponding character code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
@@ -7,9 +7,10 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FlyweightTest extends TestCase
|
||||
{
|
||||
private $characters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
|
||||
private array $characters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
|
||||
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
||||
private $fonts = ['Arial', 'Times New Roman', 'Verdana', 'Helvetica'];
|
||||
|
||||
private array $fonts = ['Arial', 'Times New Roman', 'Verdana', 'Helvetica'];
|
||||
|
||||
public function testFlyweight()
|
||||
{
|
||||
|
@@ -2,16 +2,18 @@
|
||||
|
||||
namespace DesignPatterns\Structural\Flyweight;
|
||||
|
||||
use Countable;
|
||||
|
||||
/**
|
||||
* A factory manages shared flyweights. Clients should not instantiate them directly,
|
||||
* but let the factory take care of returning existing objects or creating new ones.
|
||||
*/
|
||||
class TextFactory implements \Countable
|
||||
class TextFactory implements Countable
|
||||
{
|
||||
/**
|
||||
* @var Text[]
|
||||
*/
|
||||
private $charPool = [];
|
||||
private array $charPool = [];
|
||||
|
||||
public function get(string $name): Text
|
||||
{
|
||||
|
@@ -4,10 +4,7 @@ namespace DesignPatterns\Structural\Flyweight;
|
||||
|
||||
class Word implements Text
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
Reference in New Issue
Block a user