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 ( 959197...30aa65 )
by
unknown
03:16 queued 01:32
created

LeadFile::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
class LeadFile extends Model
8
{
9
    /**
10
     * @var integer
11
     */
12
    protected $id;
13
14
    /**
15
     * @var string
16
     */
17
    protected $name;
18
19
    /**
20
     * @var string
21
     */
22
    protected $ext;
23
24
    /**
25
     * @var string
26
     */
27
    protected $data;
28
29
    public function __construct(array $fileData = [])
30
    {
31
        if (!empty($fileData['id'])) {
32
            $this->id = (int) $fileData['id'];
33
        }
34
        if (!empty($fileData['name'])) {
35
            $this->name = $fileData['name'];
36
        }
37
        if (!empty($fileData['ext'])) {
38
            $this->ext = $fileData['ext'];
39
        }
40
        if (!empty($fileData['data'])) {
41
            $this->data = $fileData['data'];
42
        }
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function toArray()
49
    {
50
        $result = [];
51
        if (!empty($this->id)) {
52
            $result['id'] = $this->getId();
53
        }
54
        if (!empty($this->name)) {
55
            $result['name'] = $this->getName();
56
        }
57
        if (!empty($this->ext)) {
58
            $result['ext'] = $this->getExt();
59
        }
60
        if (!empty($this->data)) {
61
            $result['data'] = $this->getData();
62
        }
63
        return $result;
64
    }
65
66
    /**
67
     * @return int
68
     */
69
    public function getId()
70
    {
71
        return (int) $this->id;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getName()
78
    {
79
        return $this->name;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getExt()
86
    {
87
        return $this->ext;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getData()
94
    {
95
        return $this->data;
96
    }
97
98
    /**
99
     * @param string $path (Full path to file with name and ext)
100
     *
101
     * @return void
102
     */
103
    public function saveFile($path)
104
    {
105
        try{
106
            $content = $this->getData();
107
            if(!empty($content)){
108
                @file_put_contents($path, base64_decode($content));
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
109
            }
110
        }catch(\Exception $e){}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
111
    }
112
113
    public function validate(){
114
        return true;
115
    }
116
}
117