mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-11 09:24:01 +02:00
fixed eol and typecast
This commit is contained in:
@@ -8,30 +8,29 @@ use DesignPatterns\Structural\Flyweight\CharacterFlyweight;
|
||||
* A factory manages shared flyweights. Clients shouldn't instaniate them directly,
|
||||
* but let the factory take care of returning existing objects or creating new ones.
|
||||
*/
|
||||
class FlyweightFactory {
|
||||
|
||||
/**
|
||||
* Associative store for flyweight objects
|
||||
class FlyweightFactory
|
||||
{
|
||||
/**
|
||||
* Associative store for flyweight objects
|
||||
* @var Array
|
||||
*/
|
||||
private $pool = array();
|
||||
private $pool = array();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Magic getter
|
||||
* @param string $name
|
||||
* @return Flyweight
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!array_key_exists((string) $name, $this->pool)) {
|
||||
$this->pool[(string) $name] = new CharacterFlyweight((string) $name);
|
||||
if (!array_key_exists($name, $this->pool)) {
|
||||
$this->pool[$name] = new CharacterFlyweight($name);
|
||||
}
|
||||
return $this->pool[(string) $name];
|
||||
return $this->pool[$name];
|
||||
}
|
||||
|
||||
public function totalNumber()
|
||||
{
|
||||
return sizeof($this->pool);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user