Passed
Branch master (627165)
by Songda
02:12
created

anonymous//src/Service/EventServiceProvider.php$0   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
dl 0
loc 32
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Service;
6
7
use Symfony\Component\EventDispatcher\EventDispatcher;
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
use Yansongda\Pay\Contract\EventDispatcherInterface;
10
use Yansongda\Pay\Contract\ServiceProviderInterface;
11
use Yansongda\Pay\Pay;
12
13
class EventServiceProvider implements ServiceProviderInterface
14
{
15
    /**
16
     * @throws \Yansongda\Pay\Exception\ContainerDependencyException
17
     * @throws \Yansongda\Pay\Exception\ContainerException
18
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
19
     */
20
    public function register(Pay $pay, ?array $data = null): void
21
    {
22
        $event = new class() implements EventDispatcherInterface {
23
            public function addListener(string $eventName, $listener, int $priority = 0)
24
            {
25
            }
26
27
            public function addSubscriber(EventSubscriberInterface $subscriber)
28
            {
29
            }
30
31
            public function removeListener(string $eventName, $listener)
32
            {
33
            }
34
35
            public function removeSubscriber(EventSubscriberInterface $subscriber)
36
            {
37
            }
38
39
            public function getListeners(string $eventName = null)
40
            {
41
            }
42
43
            public function dispatch(object $event, string $eventName = null): object
44
            {
45
                return $event;
46
            }
47
48
            public function getListenerPriority(string $eventName, $listener)
49
            {
50
            }
51
52
            public function hasListeners(string $eventName = null)
53
            {
54
            }
55
        };
56
57
        if (class_exists(EventDispatcher::class)) {
58
            $event = Pay::get(EventDispatcher::class);
59
        }
60
61
        Pay::set(EventDispatcherInterface::class, $event);
62
    }
63
}
64