Test Setup Failed
Pull Request — latest (#3)
by Mark
31:31
created

TwemojiExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 11
c 1
b 0
f 1
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A configureSchema() 0 10 1
A registerEmojiTypes() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UnicornFail\Emoji\Extension\Twemoji;
6
7
use League\Configuration\ConfigurationBuilderInterface;
8
use Nette\Schema\Expect;
9
use UnicornFail\Emoji\Environment\EnvironmentBuilderInterface;
10
use UnicornFail\Emoji\Event\DocumentParsedEvent;
11
use UnicornFail\Emoji\Extension\ConfigurableExtensionInterface;
12
use UnicornFail\Emoji\Extension\TypedExtensionInterface;
13
14
final class TwemojiExtension implements ConfigurableExtensionInterface, TypedExtensionInterface
15
{
16
    public function configureSchema(ConfigurationBuilderInterface $builder): void
17
    {
18
        $builder->addSchema('twemoji', Expect::structure([
19
            'classes'     => Expect::arrayOf('string')->default(['twemoji']),
20
            'classPrefix' => Expect::string('twemoji-')->nullable(),
21
            'icon'        => Expect::bool(false)->nullable(),
22
            'relativeSvg' => Expect::bool(true),
23
            'size'        => Expect::int()->nullable(),
24
            'type'        => Expect::anyOf('png', 'svg')->default('svg'),
25
            'urlBase'     => Expect::string('https://twemoji.maxcdn.com/v/latest'),
26
        ]));
27
    }
28
29
    public function register(EnvironmentBuilderInterface $environment): void
30
    {
31
        $environment->addEventListener(DocumentParsedEvent::class, new TwemojiProcessor());
32
    }
33
34
    /** @return string[] */
35
    public function registerEmojiTypes(): array
36
    {
37
        return ['twemoji'];
38
    }
39
}
40