Issues (4)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Result.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Push notification services abstraction (http://github.com/juliangut/tify)
4
 *
5
 * @link https://github.com/juliangut/tify for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/tify/blob/master/LICENSE
8
 */
9
10
namespace Jgut\Tify;
11
12
/**
13
 * Push result abstraction.
14
 */
15
class Result implements \JsonSerializable
16
{
17
    const STATUS_SUCCESS = 'success';
18
    const STATUS_INVALID_DEVICE = 'invalidDevice';
19
    const STATUS_INVALID_MESSAGE = 'invalidMessage';
20
    const STATUS_RATE_ERROR = 'rateError';
21
    const STATUS_AUTH_ERROR = 'authError';
22
    const STATUS_SERVER_ERROR = 'serverError';
23
    const STATUS_UNKNOWN_ERROR = 'unknownError';
24
25
    /**
26
     * Device token.
27
     *
28
     * @var string
29
     */
30
    protected $token;
31
32
    /**
33
     * Result time.
34
     *
35
     * @var \DateTime
36
     */
37
    protected $date;
38
39
    /**
40
     * Result status.
41
     *
42
     * @var string
43
     */
44
    protected $status;
45
46
    /**
47
     * Result status message.
48
     *
49
     * @var string
50
     */
51
    protected $statusMessage;
52
53
    /**
54
     * @param string             $token
55
     * @param int|\DateTime|null $date
56
     * @param string             $status
57
     * @param string|null        $statusMessage
58
     *
59
     * @throws \InvalidArgumentException
60
     */
61
    public function __construct(
62
        $token,
63
        $date = null,
64
        $status = self::STATUS_SUCCESS,
65
        $statusMessage = null
66
    ) {
67
        $this->token = $token;
68
69
        if (is_int($date)) {
70
            $date = \DateTime::createFromFormat('U', (string) $date);
71
        }
72
        if ($date === null) {
73
            $date = new \DateTime('now', new \DateTimeZone('UTC'));
74
        }
75
76
        if (!$date instanceof \DateTime) {
77
            throw new \InvalidArgumentException('Wrong date value provided');
78
        }
79
        $this->setDate($date);
80
81
        $this->setStatus($status);
82
        $this->setStatusMessage($statusMessage);
83
    }
84
85
    /**
86
     * Retrieve result device token.
87
     *
88
     * @return string
89
     */
90
    public function getToken()
91
    {
92
        return $this->token;
93
    }
94
95
    /**
96
     * Set result device token.
97
     *
98
     * @param string $token
99
     *
100
     * @return $this
101
     */
102
    public function setToken($token)
103
    {
104
        $this->token = trim($token);
105
106
        return $this;
107
    }
108
109
    /**
110
     * Retrieve result time.
111
     *
112
     * @return \DateTime
113
     */
114
    public function getDate()
115
    {
116
        return $this->date;
117
    }
118
119
    /**
120
     * Set result time.
121
     *
122
     * @param \DateTime $date
123
     *
124
     * @return $this
125
     */
126
    public function setDate(\DateTime $date)
127
    {
128
        $this->date = clone $date;
129
130
        return $this;
131
    }
132
133
    /**
134
     * Retrieve result status.
135
     *
136
     * @return string
137
     */
138
    public function getStatus()
139
    {
140
        return $this->status;
141
    }
142
143
    /**
144
     * Check successful status.
145
     *
146
     * @return bool
147
     */
148
    public function isSuccess()
149
    {
150
        return $this->status === static::STATUS_SUCCESS;
151
    }
152
153
    /**
154
     * Check error status.
155
     *
156
     * @return bool
157
     */
158
    public function isError()
159
    {
160
        return $this->status !== static::STATUS_SUCCESS;
161
    }
162
163
    /**
164
     * Set result status.
165
     *
166
     * @param string $status
167
     *
168
     * @throws \InvalidArgumentException
169
     *
170
     * @return $this
171
     */
172
    public function setStatus($status)
173
    {
174
        $ref = new \ReflectionClass(self::class);
175
        if (!in_array($status, $ref->getConstants())) {
176
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid status', $status));
177
        }
178
179
        $this->status = $status;
180
181
        return $this;
182
    }
183
184
    /**
185
     * Retrieve result status message.
186
     *
187
     * @return string
188
     */
189
    public function getStatusMessage()
190
    {
191
        return $this->statusMessage;
192
    }
193
194
    /**
195
     * Check successful status message.
196
     *
197
     * @param string|null $statusMessage
198
     *
199
     * @return $this
200
     */
201
    public function setStatusMessage($statusMessage = null)
202
    {
203
        $this->statusMessage = $statusMessage !== null ? trim($statusMessage) : null;
204
205
        return $this;
206
    }
207
208
    /**
209
     * {@inheritdoc}
210
     *
211
     * @return string[]
0 ignored issues
show
Should the return type not be array<string,string>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
212
     */
213
    public function jsonSerialize()
214
    {
215
        return [
216
            'token' => $this->token,
217
            'date' => $this->date->format('c'),
218
            'status' => $this->status,
219
            'statusMessage' => $this->statusMessage,
220
        ];
221
    }
222
}
223