Failed Conditions
Pull Request — master (#537)
by Luís
07:20
created

FileQueryWriter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
declare(strict_types=1);
21
22
namespace Doctrine\DBAL\Migrations;
23
24
/**
25
 * @since  1.6.0
26
 * @author Luís Cobucci <[email protected]>
27
 */
28
final class FileQueryWriter implements QueryWriter
29
{
30
    /**
31
     * @var string
32
     */
33
    private $columnName;
34
35
    /**
36
     * @var string
37
     */
38
    private $tableName;
39
40
    /**
41
     * @var null|OutputWriter
42
     */
43
    private $outputWriter;
44
45 11
    public function __construct(string $columnName, string $tableName, ?OutputWriter $outputWriter)
46
    {
47 11
        $this->columnName   = $columnName;
48 11
        $this->tableName    = $tableName;
49 11
        $this->outputWriter = $outputWriter;
50 11
    }
51
52
    /**
53
     * TODO: move SqlFileWriter's behaviour to this class - and kill it with fire (on the next major release)
54
     */
55 10
    public function write(string $path, string $direction, array $queriesByVersion) : bool
56
    {
57 10
        $writer = new SqlFileWriter(
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\DBAL\Migrations\SqlFileWriter has been deprecated.

This class, trait or interface has been deprecated.

Loading history...
58 10
            $this->columnName,
59 10
            $this->tableName,
60 10
            $path,
61 10
            $this->outputWriter
62
        );
63
64
        // SqlFileWriter#write() returns `bool|int` but all clients expect it to be `bool` only
65 10
        return (bool) $writer->write($queriesByVersion, $direction);
66
    }
67
}
68