Completed
Push — master ( 09b86b...ba0798 )
by Andreas
20:05 queued 12s
created

LoadClassMetadataEventArgs   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 17
ccs 4
cts 9
cp 0.4444
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getDocumentManager() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Event;
6
7
use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs;
8
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
9
use Doctrine\Common\Persistence\ObjectManager;
10
use Doctrine\ODM\MongoDB\DocumentManager;
11
use const E_USER_DEPRECATED;
12
use function assert;
13
use function sprintf;
14
use function trigger_error;
15
16
/**
17
 * Class that holds event arguments for a loadMetadata event.
18
 *
19
 * @final
20
 */
21
class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
22
{
23 4
    public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager)
24
    {
25 4
        if (self::class !== static::class) {
26
            @trigger_error(sprintf('The class "%s" extends "%s" which will be final in MongoDB ODM 2.0.', static::class, self::class), E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
27
        }
28 4
        parent::__construct($classMetadata, $objectManager);
29 4
    }
30
31
    public function getDocumentManager() : DocumentManager
32
    {
33
        $dm = $this->getObjectManager();
34
        assert($dm instanceof DocumentManager);
35
        return $dm;
36
    }
37
}
38