Config   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 6
c 5
b 0
f 0
lcom 1
cbo 0
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setApiPath() 0 5 1
A setDirectory() 0 5 1
A setFileName() 0 5 1
A setExt() 0 5 1
A getData() 0 13 2
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