GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5ac723...c719eb )
by Stan
07:02
created

File   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 93
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileId() 0 4 1
A setFileId() 0 6 1
A getFileSize() 0 4 1
A setFileSize() 0 6 1
A getFilePath() 0 4 1
A setFilePath() 0 6 1
B download() 0 22 5
1
<?php
2
3
namespace Teebot\Api\Entity;
4
5
use Teebot\Api\Exception\EntityException;
6
7
class File extends AbstractEntity
8
{
9
    const ENTITY_TYPE = 'File';
10
11
    protected $file_id;
12
13
    protected $file_size;
14
15
    protected $file_path;
16
17
    /**
18
     * @return mixed
19
     */
20
    public function getFileId()
21
    {
22
        return $this->file_id;
23
    }
24
25
    /**
26
     * @param mixed $file_id
27
     *
28
     * @return $this
29
     */
30
    public function setFileId($file_id)
31
    {
32
        $this->file_id = $file_id;
33
34
        return $this;
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public function getFileSize()
41
    {
42
        return $this->file_size;
43
    }
44
45
    /**
46
     * @param mixed $file_size
47
     *
48
     * @return $this
49
     */
50
    public function setFileSize($file_size)
51
    {
52
        $this->file_size = $file_size;
53
54
        return $this;
55
    }
56
57
    /**
58
     * @return mixed
59
     */
60
    public function getFilePath()
61
    {
62
        return $this->file_path;
63
    }
64
65
    /**
66
     * @param mixed $file_path
67
     *
68
     * @return $this
69
     */
70
    public function setFilePath($file_path)
71
    {
72
        $this->file_path = $file_path;
73
74
        return $this;
75
    }
76
77
    public function download($storePath)
78
    {
79
        if (file_exists($storePath) && !is_writable($storePath)) {
80
            throw new EntityException('File "' . $storePath . '" is already exist!"');
81
        }
82
83
        $filePath = $this->getFilePath();
84
85
        if (!$filePath) {
86
            throw new EntityException('Unable to get path to file!');
87
        }
88
89
        try {
90
            $contents = file_get_contents($filePath);
91
92
            file_put_contents($storePath, $contents);
93
        } catch (\Exception $e) {
94
            throw new EntityException($e->getMessage(), $e->getCode(), $e);
95
        }
96
97
        return is_readable($storePath);
98
    }
99
}