Failed Conditions
Push — master ( 4967a2...19868a )
by Jonathan
10s
created

OrmSchemaProvider::isEntityManager()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Migrations\Provider;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Doctrine\ORM\Tools\SchemaTool;
10
use UnexpectedValueException;
11
12
final class OrmSchemaProvider implements SchemaProviderInterface
13
{
14
    /** @var EntityManagerInterface */
15
    private $entityManager;
16
17 3
    public function __construct(EntityManagerInterface $em)
18
    {
19 3
        $this->entityManager = $em;
20 3
    }
21
22 3
    public function createSchema() : Schema
23
    {
24 3
        $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
25
26 3
        if (empty($metadata)) {
27 1
            throw new UnexpectedValueException('No mapping information to process');
28
        }
29
30 2
        $tool = new SchemaTool($this->entityManager);
31
32 2
        return $tool->getSchemaFromMetadata($metadata);
33
    }
34
}
35