Token::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CL\ComposerInit;
4
5
/**
6
 * @author    Ivan Kerin <[email protected]>
7
 * @copyright (c) 2014 Clippings Ltd.
8
 * @license   http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class Token
11
{
12
    /**
13
     * @var string
14
     */
15
    private $filename;
16
17
    /**
18
     * @param string $filename
19
     */
20 1
    public function __construct($filename)
21
    {
22 1
        $this->filename = $filename;
23 1
    }
24
25
    /**
26
     * @return string
27
     */
28 1
    public function getFilename()
29
    {
30 1
        return $this->filename;
31
    }
32
33
    /**
34
     * @return string|null
35
     */
36 1
    public function get()
37
    {
38 1
        if (file_exists($this->filename)) {
39 1
            return file_get_contents($this->filename);
40
        }
41 1
    }
42
43
    /**
44
     * @param string $token
45
     */
46 1
    public function set($token)
47
    {
48 1
        file_put_contents($this->filename, $token);
49
50 1
        return $this;
51
    }
52
}
53