Passed
Push — main ( 95b369...5c384e )
by Michiel
17:35 queued 12s
created

LiquibaseDbDocTask   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 17
dl 0
loc 49
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setOutputDir() 0 3 1
A checkParams() 0 20 5
A main() 0 4 1
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
namespace Phing\Task\Ext;
22
23
use Phing\Exception\BuildException;
24
25
/**
26
 * Task to create a javadoc-like documentation based on current database and
27
 * changelog.
28
 *
29
 * @author  Stephan Hochdoerfer <[email protected]>
30
 * @since   2.4.10
31
 * @package phing.tasks.ext.liquibase
32
 */
33
class LiquibaseDbDocTask extends AbstractLiquibaseTask
34
{
35
    protected $outputDir;
36
37
    /**
38
     * Sets the output directory where the documentation gets generated to.
39
     *
40
     * @param string the output directory
0 ignored issues
show
Bug introduced by
The type Phing\Task\Ext\the was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
     */
42
    public function setOutputDir($outputDir)
43
    {
44
        $this->outputDir = $outputDir;
45
    }
46
47
    /**
48
     * @see AbstractTask::checkParams()
49
     */
50
    protected function checkParams()
51
    {
52
        parent::checkParams();
53
54
        if ((null === $this->outputDir) or !is_dir($this->outputDir)) {
55
            if (!mkdir($this->outputDir, 0777, true)) {
56
                throw new BuildException(
57
                    sprintf(
58
                        'The directory "%s" does not exist and could not be created!',
59
                        $this->outputDir
60
                    )
61
                );
62
            }
63
        }
64
65
        if (!is_writable($this->outputDir)) {
66
            throw new BuildException(
67
                sprintf(
68
                    'The directory "%s" is not writable!',
69
                    $this->outputDir
70
                )
71
            );
72
        }
73
    }
74
75
    /**
76
     * @see Task::main()
77
     */
78
    public function main()
79
    {
80
        $this->checkParams();
81
        $this->execute('dbdoc', escapeshellarg($this->outputDir));
82
    }
83
}
84