|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of skillshare/formatphp |
| 5 | + * |
| 6 | + * skillshare/formatphp is open source software: you can distribute |
| 7 | + * it and/or modify it under the terms of the MIT License |
| 8 | + * (the "License"). You may not use this file except in |
| 9 | + * compliance with the License. |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | + * implied. See the License for the specific language governing |
| 15 | + * permissions and limitations under the License. |
| 16 | + * |
| 17 | + * @copyright Copyright (c) Skillshare, Inc. <https://www.skillshare.com> |
| 18 | + * @license https://opensource.org/licenses/MIT MIT License |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | +namespace FormatPHP\PseudoLocale\Locale; |
| 24 | + |
| 25 | +use FormatPHP\Icu\MessageFormat\Parser; |
| 26 | +use Zalgo\Mood; |
| 27 | +use Zalgo\Soul; |
| 28 | +use Zalgo\Zalgo; |
| 29 | + |
| 30 | +/** |
| 31 | + * T̫̺̳o̬̜ ì̬͎̲̟nv̖̗̻̣̹̕o͖̗̠̜̤k͍͚̹͖̼e̦̗̪͍̪͍ ̬ͅt̕h̠͙̮͕͓e̱̜̗͙̭ ̥͔̫͙̪͍̣͝ḥi̼̦͈̼v҉̩̟͚̞͎e͈̟̻͙̦̤-m̷̘̝̱í͚̞̦̳n̝̲̯̙̮͞d̴̺̦͕̫ ̗̭̘͎͖r̞͎̜̜͖͎̫͢ep͇r̝̯̝͖͉͎̺e̴s̥e̵̖̳͉͍̩̗n̢͓̪͕̜̰̠̦t̺̞̰i͟n҉̮̦̖̟g̮͍̱̻͍̜̳ ̳c̖̮̙̣̰̠̩h̷̗͍̖͙̭͇͈a̧͎̯̹̲̺̫ó̭̞̜̣̯͕s̶̤̮̩̘.̨̻̪̖͔ |
| 32 | + * ̳̭̦̭̭̦̞́I̠͍̮n͇̹̪̬v̴͖̭̗̖o̸k҉̬̤͓͚̠͍i͜n̛̩̹͉̘̹g͙ ̠̥ͅt̰͖͞h̫̼̪e̟̩̝ ̭̠̲̫͔fe̤͇̝̱e͖̮̠̹̭͖͕l͖̲̘͖̠̪i̢̖͎̮̗̯͓̩n̸̰g̙̱̘̗͚̬ͅ ͍o͍͍̩̮͢f̖͓̦̥ ̘͘c̵̫̱̗͚͓̦h͝a̝͍͍̳̣͖͉o͙̟s̤̞.̙̝̭̣̳̼͟ |
| 33 | + * ̢̻͖͓̬̞̰̦W̮̲̝̼̩̝͖i͖͖͡ͅt̘̯͘h̷̬̖̞̙̰̭̳ ̭̪̕o̥̤̺̝̼̰̯͟ṳ̞̭̤t̨͚̥̗ ̟̺̫̩̤̳̩o̟̰̩̖ͅr̞̘̫̩̼d̡͍̬͎̪̺͚͔e͓͖̝̙r̰͖̲̲̻̠.̺̝̺̟͈ |
| 34 | + * ̣̭T̪̩̼h̥̫̪͔̀e̫̯͜ ̨N̟e҉͔̤zp̮̭͈̟é͉͈ṛ̹̜̺̭͕d̺̪̜͇͓i̞á͕̹̣̻n͉͘ ̗͔̭͡h̲͖̣̺̺i͔̣̖̤͎̯v̠̯̘͖̭̱̯e̡̥͕-m͖̭̣̬̦͈i͖n̞̩͕̟̼̺͜d̘͉ ̯o̷͇̹͕̦f̰̱ ̝͓͉̱̪̪c͈̲̜̺h̘͚a̞͔̭̰̯̗̝o̙͍s͍͇̱͓.̵͕̰͙͈ͅ ̯̞͈̞̱̖Z̯̮̺̤̥̪̕a͏̺̗̼̬̗ḻg͢o̥̱̼.̺̜͇͡ͅ ̴͓͖̭̩͎̗ |
| 35 | + * ̧̪͈̱̹̳͖͙H̵̰̤̰͕̖e̛ ͚͉̗̼̞w̶̩̥͉̮h̩̺̪̩͘ͅọ͎͉̟ ̜̩͔̦̘ͅW̪̫̩̣̲͔̳a͏͔̳͖i͖͜t͓̤̠͓͙s̘̰̩̥̙̝ͅ ̲̠̬̥Be̡̙̫̦h̰̩i̛̫͙͔̭̤̗̲n̳͞d̸ ͎̻͘T̛͇̝̲̹̠̗ͅh̫̦̝ͅe̩̫͟ ͓͖̼W͕̳͎͚̙̥ą̙l̘͚̺͔͞ͅl̳͍̙̤̤̮̳.̢ |
| 36 | + * ̟̺̜̙͉Z̤̲̙̙͎̥̝A͎̣͔̙͘L̥̻̗̳̻̳̳͢G͉̖̯͓̞̩̦O̹̹̺!̙͈͎̞̬ * |
| 37 | + */ |
| 38 | +class XxZa extends AbstractLocale |
| 39 | +{ |
| 40 | + private Zalgo $zalgo; |
| 41 | + |
| 42 | + public function __construct() |
| 43 | + { |
| 44 | + /** @var Mood $mood */ |
| 45 | + $mood = Mood::soothed(); |
| 46 | + |
| 47 | + $this->zalgo = new Zalgo(new Soul(), $mood); |
| 48 | + } |
| 49 | + |
| 50 | + protected function generate(Parser\Type\ElementCollection $elementCollection): Parser\Type\ElementCollection |
| 51 | + { |
| 52 | + foreach ($elementCollection as $element) { |
| 53 | + if ($element instanceof Parser\Type\LiteralElement) { |
| 54 | + /** @var string $theWordOfZalgo */ |
| 55 | + $theWordOfZalgo = $this->zalgo->speaks($element->value); |
| 56 | + $element->value = $theWordOfZalgo; |
| 57 | + } elseif ($element instanceof Parser\Type\PluralElement || $element instanceof Parser\Type\SelectElement) { |
| 58 | + foreach ($element->options as $option) { |
| 59 | + $this->generate($option->value); |
| 60 | + } |
| 61 | + } elseif ($element instanceof Parser\Type\TagElement) { |
| 62 | + $this->generate($element->children); |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + return $elementCollection; |
| 67 | + } |
| 68 | +} |
0 commit comments