LlumRCParser   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 4 1
A getCredentials() 0 7 3
A getGitHubUsername() 0 7 2
1
<?php
2
3
namespace Acacha\Llum\Parser;
4
5
/**
6
 * Class LlumRCParser.
7
 *
8
 * @package Acacha\Llum\Parser
9
 */
10
use Acacha\Llum\LlumRCFile;
11
12
/**
13
 * Class LlumRCParser
14
 * @package Acacha\Llum\Parser
15
 */
16
class LlumRCParser
17
{
18
19
    /**
20
     * File to parse.
21
     *
22
     * @var
23
     */
24
    protected $file;
25
26
    /**
27
     * LlumRCParser constructor.
28
     * @param $file
29
     */
30
    public function __construct(LlumRCFile $file)
31
    {
32
        $this->file = $file;
33
    }
34
35
    /**
36
     * Parse llumrc file.
37
     *
38
     * @return array
39
     */
40
    public function parse()
41
    {
42
        return parse_ini_file($this->file->path());
43
    }
44
45
    /**
46
     * Get credentials from config file.
47
     *
48
     * @return array
49
     */
50
    public function getCredentials()
51
    {
52
        $rc_file = $this->parse();
53
        if ( array_key_exists('username',$rc_file) && array_key_exists('username',$rc_file)) {
54
            return [$rc_file['username'],$rc_file['token']];
55
        }
56
    }
57
58
    /**
59
     * Get github username from config file.
60
     *
61
     * @return array
62
     */
63
    public function getGitHubUsername()
64
    {
65
        $rc_file = $this->parse();
66
        if ( array_key_exists('username',$rc_file)) {
67
            return $rc_file['username'];
68
        }
69
    }
70
71
72
}