1 | <?php |
||
18 | class CloudBuilder |
||
19 | { |
||
20 | /** @var WordsList */ |
||
21 | protected $list; |
||
22 | /** @var int */ |
||
23 | protected $width = 800; |
||
24 | /** @var int */ |
||
25 | protected $height = 600; |
||
26 | /** @var string */ |
||
27 | protected $font; |
||
28 | /** @var string */ |
||
29 | protected $backgroundColor = '#ffffff'; |
||
30 | /** @var FontSizeGeneratorInterface */ |
||
31 | protected $sizeGenerator; |
||
32 | /** @var string */ |
||
33 | protected $placerName; |
||
34 | /** @var int */ |
||
35 | protected $minFontSize = 10; |
||
36 | /** @var int */ |
||
37 | protected $maxFontSize = 60; |
||
38 | /** @var FontsFactory */ |
||
39 | protected $fontsFactory; |
||
40 | /** @var bool */ |
||
41 | protected $precise = false; |
||
42 | |||
43 | 4 | protected function __construct(FontsFactory $fontsFactory) |
|
44 | { |
||
45 | 4 | $this->fontsFactory = $fontsFactory; |
|
46 | 4 | } |
|
47 | |||
48 | /** |
||
49 | * @return CloudBuilder |
||
50 | */ |
||
51 | 4 | public static function create(FontsFactory $fontsFactory) |
|
52 | { |
||
53 | 4 | return new self($fontsFactory); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param int $width |
||
58 | * @param int $height |
||
59 | * @return CloudBuilder |
||
60 | */ |
||
61 | 2 | public function setDimension($width, $height) |
|
67 | |||
68 | 2 | public function setBackgroundColor($color) |
|
73 | |||
74 | 4 | public function setFont($name) |
|
75 | { |
||
76 | 4 | $this->font = $name; |
|
77 | 4 | return $this; |
|
78 | } |
||
79 | |||
80 | public function setSizeGenerator(FontSizeGeneratorInterface $generator) |
||
85 | |||
86 | public function setFontSizes($minSize, $maxSize) |
||
87 | { |
||
88 | $this->minFontSize = $minSize; |
||
89 | $this->maxFontSize = $maxSize; |
||
90 | return $this; |
||
91 | } |
||
92 | |||
93 | 1 | public function setPlacer($name) |
|
102 | |||
103 | public function setPrecise() |
||
104 | { |
||
105 | $this->precise = true; |
||
106 | } |
||
107 | |||
108 | 3 | public function useList(WordsList $list) |
|
113 | |||
114 | 4 | public function build() |
|
135 | |||
136 | 3 | protected function addWords(Cloud $cloud, WordsList $list) |
|
162 | |||
163 | 3 | protected function placeWords(Cloud $cloud) |
|
186 | |||
187 | } |
||
188 |