GenerateProxiesCommand::fire()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 14
nc 4
nop 0
1
<?php namespace Nord\Lumen\Doctrine\ORM\Console;
2
3
class GenerateProxiesCommand extends DoctrineCommand
4
{
5
6
    /**
7
     * @var string
8
     */
9
    protected $name = 'doctrine:generate:proxies';
10
11
    /**
12
     * @var string
13
     */
14
    protected $description = 'Generates proxies for entities.';
15
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function fire()
21
    {
22
        $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();
23
24
        if (empty($metadata)) {
25
            $this->error('No metadata found.');
26
            exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method fire() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
27
        }
28
29
        $directory = array_get($this->laravel['config'], 'doctrine.proxy.directory');
30
31
        if (! $directory) {
32
            $this->error('Proxy directory must be set.');
33
            exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method fire() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
34
        }
35
36
        $this->info('Generating proxies ...');
37
38
        foreach ($metadata as $item) {
39
            $this->line($item->name);
40
        }
41
42
        $this->getEntityManager()->getProxyFactory()->generateProxyClasses($metadata, $directory);
43
44
        $this->info('Proxies created!');
45
    }
46
}
47