emoji-catalog/tasks/CatalogUpdateTask.php
2022-11-06 16:35:30 +01:00

24 lines
812 B
PHP

<?php declare(strict_types=1);
namespace Jawira\EmojiTask;
use SplFileObject;
class CatalogUpdateTask extends AbstractEmojiTask
{
function main()
{
$file = new SplFileObject('docs/catalog.md', 'w+');
$file->fwrite(file_get_contents('resources/templates/catalog-header.md.dist'));
foreach (file('resources/unicode/emoji-test.txt') as $line) {
$matches = $this->extractParts($line);
if (!is_array($matches)) {
continue;
}
$emoji = $this->codepointsToEmoji($matches['CODEPOINTS']);
$constantName = $this->normalizeEmojiName($matches['NAME']);
$file->fwrite(sprintf("| %s | %s | %s | %s |%s", $matches['NAME'], $emoji, trim($matches['CODEPOINTS']), $constantName, PHP_EOL));
}
}
}