Config::setApiPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace LoteriaApi;
4
5
class Config
6
{
7
    private $apiPath;
8
    private $directory;
9
    private $filename;
10
    private $ext;
11
12
    public function setApiPath($apiPath)
13
    {
14
        $this->apiPath = $apiPath;
15
        return $this;
16
    }
17
    
18
    public function setDirectory($directory)
19
    {
20
        $this->directory = $directory;
21
        return $this;
22
    }
23
    
24
    public function setFileName($filename)
25
    {
26
        $this->filename = $filename;
27
        return $this;
28
    }
29
30
    public function setExt($ext)
31
    {
32
        $this->ext = $ext;
33
        return $this;
34
    }
35
36
    public function getData()
37
    {
38
        $file = $this->apiPath .
39
            $this->directory . DS .
40
            $this->filename . '.' .
41
            $this->ext;
42
43
        if (!is_file($file)) {
44
            throw new \Exception('File does not exist');
45
        }
46
47
        return parse_ini_file($file, true);
48
    }
49
}
50