Completed
Push — master ( 44ea8e...1ef346 )
by Bukashk0zzz
12:10
created

normalizeOrigin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Bukashk0zzzLiipImagineSerializationBundle
5
 *
6
 * (c) Denis Golubovskiy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bukashk0zzz\LiipImagineSerializationBundle\Tests\EventSubscriber;
13
14
use Bukashk0zzz\LiipImagineSerializationBundle\Event\UrlNormalizerEvent;
15
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
17
/**
18
 * Bukashk0zzzSerializationEventSubscriber
19
 *
20
 * @author Denis Golubovskiy <[email protected]>
21
 */
22
class Bukashk0zzzSerializationEventSubscriber implements EventSubscriberInterface
23
{
24
    /**
25
     * @return array
26
     */
27
    public static function getSubscribedEvents()
28
    {
29
        return [
30
            UrlNormalizerEvent::ORIGIN => [
31
                ['normalizeOrigin', 10],
32
            ],
33
            UrlNormalizerEvent::FILTERED => [
34
                ['normalizeFiltered', 10],
35
            ],
36
        ];
37
    }
38
39
    /**
40
     * @param UrlNormalizerEvent $event
41
     */
42
    public function normalizeOrigin(UrlNormalizerEvent $event)
43
    {
44
        $event->setUrl(str_replace('photo', 'newPhoto', $event->getUrl()));
45
    }
46
47
    /**
48
     * @param UrlNormalizerEvent $event
49
     */
50
    public function normalizeFiltered(UrlNormalizerEvent $event)
51
    {
52
        $event->setUrl(str_replace('example.com', 'img.example.com', $event->getUrl()));
53
    }
54
}
55