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

EventDispatcherCheck::isPSR14Compliant()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 3
rs 10
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