Passed
Push — master ( 601cfd...7bcbf1 )
by Michiel
22:46
created

AutoloaderTask::setAutoloaderPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 please see
17
 * <http://phing.info>.
18
 */
19
20
namespace Phing\Task\System;
21
22
use Phing\Exception\BuildException;
23
use Phing\Task;
24
25
/**
26
 * @author Max Romanovsky <[email protected]>
27
 * @package phing.tasks.ext
28
 */
29
class AutoloaderTask extends Task
30
{
31
    public const DEFAULT_AUTOLOAD_PATH = 'vendor/autoload.php';
32
33
    private $autoloaderPath = self::DEFAULT_AUTOLOAD_PATH;
34
35
    /**
36
     * @return string
37
     */
38
    public function getAutoloaderPath()
39
    {
40
        return $this->autoloaderPath;
41
    }
42
43
    /**
44
     * @param string $autoloaderPath
45
     */
46
    public function setAutoloaderPath($autoloaderPath)
47
    {
48
        $this->autoloaderPath = $autoloaderPath;
49
    }
50
51
    /**
52
     *  Called by the project to let the task do it's work. This method may be
53
     *  called more than once, if the task is invoked more than once. For
54
     *  example, if target1 and target2 both depend on target3, then running
55
     *  <em>phing target1 target2</em> will run all tasks in target3 twice.
56
     *
57
     *  Should throw a BuildException if someting goes wrong with the build
58
     *
59
     *  This is here. Must be overloaded by real tasks.
60
     */
61
    public function main()
62
    {
63
        if (is_dir($this->autoloaderPath) || !is_readable($this->autoloaderPath)) {
64
            throw new BuildException(
65
                sprintf(
66
                    'Provided autoloader file "%s" is not a readable file',
67
                    $this->autoloaderPath
68
                )
69
            );
70
        }
71
        $this->log('Loading autoloader from ' . $this->autoloaderPath);
72
        include_once $this->autoloaderPath;
73
    }
74
}
75