Bukashk0zzzSerializationEventSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 11 1
A normalizeOrigin() 0 4 1
A normalizeFiltered() 0 4 1
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the Bukashk0zzzLiipImagineSerializationBundle
4
 *
5
 * (c) Denis Golubovskiy <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Bukashk0zzz\LiipImagineSerializationBundle\Tests\EventSubscriber;
12
13
use Bukashk0zzz\LiipImagineSerializationBundle\Event\UrlNormalizerEvent;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
16
/**
17
 * Bukashk0zzzSerializationEventSubscriber
18
 */
19
class Bukashk0zzzSerializationEventSubscriber implements EventSubscriberInterface
20
{
21
    /**
22
     * @return mixed[]
23
     */
24
    public static function getSubscribedEvents(): array
25
    {
26
        return [
27
            UrlNormalizerEvent::ORIGIN => [
28
                ['normalizeOrigin', 10],
29
            ],
30
            UrlNormalizerEvent::FILTERED => [
31
                ['normalizeFiltered', 10],
32
            ],
33
        ];
34
    }
35
36
    public function normalizeOrigin(UrlNormalizerEvent $event): void
37
    {
38
        $event->setUrl(\str_replace('photo', 'newPhoto', $event->getUrl()));
39
    }
40
41
    public function normalizeFiltered(UrlNormalizerEvent $event): void
42
    {
43
        $event->setUrl(\str_replace('example.com', 'img.example.com', $event->getUrl()));
44
    }
45
}
46