Completed
Push — master ( ca8257...5c71d6 )
by Freek
02:49
created

DbDumper::checkIfDumpWasSuccessFull()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 16
rs 9.2
cc 4
eloc 8
nc 4
nop 2
1
<?php
2
3
namespace Spatie\DbDumper;
4
5
use Spatie\DbDumper\Exceptions\DumpFailed;
6
use Symfony\Component\Process\Process;
7
8
abstract class DbDumper
9
{
10
    public static function create()
11
    {
12
        return new static();
13
    }
14
15
    protected function checkIfDumpWasSuccessFull(Process $process, string $outputFile) : bool
16
    {
17
        if (!$process->isSuccessful()) {
18
            throw DumpFailed::processDidNotEndSuccessfully($this->process);
0 ignored issues
show
Bug introduced by
The property process does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
        }
20
21
        if (!file_exists($outputFile)) {
22
            throw DumpFailed::dumpfileWasNotCreated();
23
        }
24
25
        if (filesize($outputFile) === 0) {
26
            throw DumpFailed::dumpfileWasEmpty();
27
        }
28
29
        return true;
30
    }
31
}
32