LlumRCParser::getGitHubUsername()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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
}