1 | <?php |
||
14 | class PlacerFactory |
||
15 | { |
||
16 | /** @var PlacerFactory */ |
||
17 | protected static $instance; |
||
18 | |||
19 | /** @var array */ |
||
20 | protected $placers = array( |
||
21 | 'Circular' => CircularPlacer::class, |
||
22 | 'Wordle' => WordlePlacer::class, |
||
23 | 'Spirangle' => SpiranglePlacer::class, |
||
24 | 'Linear Horizontal' => LinearHorizontalPlacer::class, |
||
25 | 'Linear Vertical' => LinearVerticalPlacer::class, |
||
26 | 'Lissajou' => LissajouPlacer::class, |
||
27 | ); |
||
28 | |||
29 | protected function __construct() { } |
||
30 | |||
31 | 4 | public static function getInstance() |
|
38 | |||
39 | 1 | public function getPlacersNames() |
|
40 | { |
||
41 | 1 | return array_keys($this->placers); |
|
42 | } |
||
43 | |||
44 | 2 | public function getDefaultPlacer($imgWidth, $imgHeight) |
|
48 | |||
49 | 4 | public function getPlacer($name, $imgWidth, $imgHeight, $increment = 10) |
|
50 | { |
||
51 | 4 | $className = $this->getPlacerClass($name); |
|
52 | 4 | return new $className($imgWidth, $imgHeight, $increment); |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string $name |
||
57 | * @return PlacerInterface |
||
58 | * @throws \InvalidArgumentException |
||
59 | */ |
||
60 | 4 | protected function getPlacerClass($name) |
|
68 | } |