Passed
Pull Request — master (#95)
by Alessandro
02:29
created

EventDispatcherCheck   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isPSR14Compliant() 0 3 2
A shouldUseLegacyProxy() 0 3 2
1
<?php
2
3
namespace Facile\MongoDbBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event;
6
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
7
8
/**
9
 * This class provides the checks needed to avoid the EventDispatcher deprecations from 4.3
10
 * The Event class has been removed in Symfony 5, so its absence is used as a trigger to stop using the LegacyEventDispatcherProxy.
11
 */
12
class EventDispatcherCheck
13
{
14
    public static function isPSR14Compliant(): bool
15
    {
16
        return ! class_exists(Event::class) || class_exists(LegacyEventDispatcherProxy::class);
17
    }
18
19
    public static function shouldUseLegacyProxy(): bool
20
    {
21
        return ! class_exists(Event::class) && class_exists(LegacyEventDispatcherProxy::class);
22
    }
23
}
24