1 | <?php |
||
10 | class Kojimify |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $wordsSeparator; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $charactersGlue; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $linesGlue; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $wordsGlue; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $geniusMark; |
||
36 | |||
37 | /** |
||
38 | * Kojimify constructor. |
||
39 | * |
||
40 | * @param string $wordSeparator Character that is used as a words separator |
||
41 | * @param string $charactersGlue Character that will be put between characters of a kojimified word |
||
42 | * @param string $linesGlue Character that will be put between lines of a kojimified word |
||
43 | * @param string $wordsGlue Character that will be used to join words of a kojimified text |
||
44 | * @param string $geniusMark Character that is used to detect whether the text has increased genius |
||
45 | */ |
||
46 | 23 | public function __construct( |
|
60 | |||
61 | /** |
||
62 | * Bootstrap method that kojimifies the whole text. |
||
63 | * |
||
64 | * @param string $text |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 3 | public function processText(string $text): string |
|
86 | |||
87 | /** |
||
88 | * Splits source text into separate words. |
||
89 | * |
||
90 | * @param string $text |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | 7 | public function splitText(string $text): array |
|
102 | |||
103 | /** |
||
104 | * Kojimifies a single word. |
||
105 | * |
||
106 | * @param string $word |
||
107 | * @param bool $isGenius |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 7 | public function processWord(string $word, bool $isGenius): string |
|
129 | |||
130 | /** |
||
131 | * Detects if the text has increased genius. |
||
132 | * |
||
133 | * @param string $text |
||
134 | * |
||
135 | * @return bool |
||
136 | */ |
||
137 | 12 | public function isGenius(string $text): bool |
|
144 | |||
145 | /** |
||
146 | * Removes a genius mark from the text. |
||
147 | * |
||
148 | * @param string $text |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | 6 | public function getCleanText(string $text): string |
|
160 | |||
161 | /** |
||
162 | * Builds kojimified text from kojimified words. |
||
163 | * |
||
164 | * @param array $words |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | 6 | public function buildText(array $words): string |
|
174 | } |
||
175 |