Completed
Push — master ( fdad86...4add92 )
by Alessandro
08:39
created

PHPUnitConfig::getPhpunitOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Paraunit\Configuration;
4
5
/**
6
 * Class PHPUnitConfig
7
 * @package Paraunit\Configuration
8
 */
9
class PHPUnitConfig
10
{
11
    const DEFAULT_FILE_NAME = 'phpunit.xml.dist';
12
13
    /** @var string */
14
    private $configFile;
15
    
16
    /** @var  PHPUnitOption[] */
17
    private $phpunitOptions;
18
19
    /**
20
     * @param string $inputPathOrFileName
21
     * @throws \InvalidArgumentException
22
     */
23
    public function __construct($inputPathOrFileName)
24
    {
25
        $inputPathOrFileName = realpath($inputPathOrFileName);
26
27
        if (false === $inputPathOrFileName) {
28
            throw new \InvalidArgumentException('Config path/file provided is not valid (does it exist?)');
29
        }
30
31
        $configFile = is_dir($inputPathOrFileName)
32
            ? $inputPathOrFileName . DIRECTORY_SEPARATOR . self::DEFAULT_FILE_NAME
33
            : $inputPathOrFileName;
34
35
        if (! is_file($configFile) || ! is_readable($configFile)) {
36
            throw new \InvalidArgumentException('Config file ' . $configFile . ' does not exist or is not readable');
37
        }
38
39
        $this->configFile = $configFile;
40
        $this->phpunitOptions = array();
41
    }
42
43
    /**
44
     * Get the full path for this configuration file
45
     * @return string
46
     */
47
    public function getFileFullPath()
48
    {
49
        return $this->configFile;
50
    }
51
52
    /**
53
     * Get the directory which contains this configuration file
54
     * @return string
55
     */
56
    public function getDirectory()
57
    {
58
        return dirname($this->configFile);
59
    }
60
61
    /**
62
     * @param PHPUnitOption $option
63
     */
64
    public function addPhpunitOption(PHPUnitOption $option)
65
    {
66
        $this->phpunitOptions[] = $option;
67
    }
68
69
    /**
70
     * @return PHPUnitOption[]
71
     */
72
    public function getPhpunitOptions()
73
    {
74
        return $this->phpunitOptions;
75
    }
76
}
77