mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-22 08:33:58 +01:00
Fixed style
This commit is contained in:
parent
2888ac456a
commit
c8e0c74f46
@ -11,8 +11,6 @@ class BookList implements \Countable
|
||||
if (isset($this->books[$bookNumberToGet])) {
|
||||
return $this->books[$bookNumberToGet];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function addBook(Book $book)
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace DesignPatterns\Behavioral\TemplateMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class Journey
|
||||
{
|
||||
/**
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace DesignPatterns\Creational\Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface BuilderInterface
|
||||
{
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ class FacadeTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Computer $facade
|
||||
* @param Computer $facade
|
||||
* @param OsInterface $os
|
||||
* @dataProvider getComputer
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@ class CharacterFlyweight implements FlyweightInterface
|
||||
/**
|
||||
* 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;
|
||||
@ -25,7 +26,7 @@ class CharacterFlyweight implements FlyweightInterface
|
||||
|
||||
/**
|
||||
* Clients supply the context-dependent information that the flyweight needs to draw itself
|
||||
* For flyweights representing characters, extrinsic state usually contains e.g. the font
|
||||
* For flyweights representing characters, extrinsic state usually contains e.g. the font.
|
||||
*
|
||||
* @param string $font
|
||||
*/
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace DesignPatterns\Structural\Flyweight;
|
||||
|
||||
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.
|
||||
@ -11,16 +9,17 @@ use DesignPatterns\Structural\Flyweight\CharacterFlyweight;
|
||||
class FlyweightFactory
|
||||
{
|
||||
/**
|
||||
* Associative store for flyweight objects
|
||||
* Associative store for flyweight objects.
|
||||
*
|
||||
* @var Array
|
||||
* @var array
|
||||
*/
|
||||
private $pool = array();
|
||||
|
||||
/**
|
||||
* Magic getter
|
||||
* Magic getter.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Flyweight
|
||||
*/
|
||||
public function __get($name)
|
||||
@ -28,7 +27,7 @@ class FlyweightFactory
|
||||
if (!array_key_exists($name, $this->pool)) {
|
||||
$this->pool[$name] = new CharacterFlyweight($name);
|
||||
}
|
||||
|
||||
|
||||
return $this->pool[$name];
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace DesignPatterns\Structural\Flyweight;
|
||||
|
||||
/**
|
||||
* An interface through which flyweights can receive and act on extrinsic state
|
||||
* An interface through which flyweights can receive and act on extrinsic state.
|
||||
*/
|
||||
interface FlyweightInterface
|
||||
{
|
||||
|
@ -6,12 +6,12 @@ use DesignPatterns\Structural\Flyweight\FlyweightFactory;
|
||||
|
||||
/**
|
||||
* FlyweightTest demonstrates how a client would use the flyweight structure
|
||||
* You don't have to change the code of your client
|
||||
* You don't have to change the code of your client.
|
||||
*/
|
||||
class FlyweightTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $characters = array('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');
|
||||
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', );
|
||||
private $fonts = array('Arial', 'Times New Roman', 'Verdana', 'Helvetica');
|
||||
|
||||
// This is about the number of characters in a book of average length
|
||||
@ -31,6 +31,6 @@ class FlyweightTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
// Flyweight pattern ensures that instances are shared
|
||||
// instead of having hundreds of thousands of individual objects
|
||||
$this->assertLessThanOrEqual($factory->totalNumber(), sizeof($this->characters));
|
||||
$this->assertLessThanOrEqual($factory->totalNumber(), count($this->characters));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user