LaravelSchemaCrawler::crawl()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
3
namespace DanielWerner\LaravelSchemaCrawler;
4
5
use Symfony\Component\Process\Process;
6
use Symfony\Component\Process\Exception\ProcessFailedException;
7
8
class LaravelSchemaCrawler
9
{
10
    /**
11
     * @param SchemaCrawlerArguments|null $arguments
12
     * @return string|null
13
     */
14
    public function crawl(?SchemaCrawlerArguments $arguments = null) : ?string
15
    {
16
        if ($arguments === null) {
17
            $arguments = new SchemaCrawlerArguments();
18
        }
19
20
        $crawlerArgumentsArray = $arguments->toArray();
21
        $command = __DIR__.'/../bin/schemacrawler/'.config('laravel-schemacrawler.schemacrawler_executable');
22
        array_unshift($crawlerArgumentsArray, $command);
23
24
        $process = new Process($crawlerArgumentsArray);
25
        $process->run();
26
27
        if ($process->isSuccessful()) {
28
            return $arguments->getOutputFile();
29
        }
30
31
        throw new ProcessFailedException($process);
32
    }
33
}
34