Issues (41)

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.

Integer.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
/*
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\System;
13
14
/**
15
 * Integer Class.
16
 *
17
 * @author Karel Osorio Ramírez <[email protected]>
18
 */
19
class Integer extends Number
20
{
21
    /**
22
     * @param int $value
23
     *
24
     * @return \Cubiche\Domain\System\Integer
25
     */
26
    public static function fromNative($value)
27
    {
28
        return new static($value);
29
    }
30
31
    /**
32
     * @param int $value
33
     *
34
     * @throws \InvalidArgumentException
35
     */
36
    protected function __construct($value)
37
    {
38
        $filteredValue = \filter_var($value, FILTER_VALIDATE_INT);
39
        if ($filteredValue === false) {
40
            throw new \InvalidArgumentException(sprintf(
41
                'Argument "%s" is invalid. Allowed types for argument are "int".',
42
                $value
43
            ));
44
        }
45
46
        $this->value = $value;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toInteger(RoundingMode $roundingMode = null)
53
    {
54
        return new self($this->value);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function toReal()
61
    {
62
        return Real::fromNative($this->value);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function toDecimal()
69
    {
70
        return Decimal::fromNative($this->value);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function isInfinite()
77
    {
78
        return false;
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function isPositive()
85
    {
86
        return $this->value > 0;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function isNegative()
93
    {
94
        return $this->value < 0;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function isZero()
101
    {
102
        return $this->value === 0;
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    protected function invertedAdd(Number $x)
109
    {
110
        return $x->addInteger($this);
111
    }
112
113
    /**
114
     * {@inheritdoc}
115
     */
116
    public function addInteger(Integer $x)
117
    {
118
        return new static($this->toNative() + $x->toNative());
119
    }
120
121
    /**
122
     * {@inheritdoc}
123
     */
124
    public function addReal(Real $x)
125
    {
126
        return $this->toReal()->addReal($x);
127
    }
128
129
    /**
130
     * {@inheritdoc}
131
     */
132
    public function addDecimal(Decimal $x, $scale = null)
133
    {
134
        return $this->toDecimal()->addDecimal($x, $scale);
135
    }
136
137
    /**
138
     * {@inheritdoc}
139
     */
140
    protected function invertedSub(Number $x)
141
    {
142
        return $x->subInteger($this);
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function subInteger(Integer $x)
149
    {
150
        return new static($this->toNative() - $x->toNative());
151
    }
152
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public function subReal(Real $x)
157
    {
158
        return $this->toReal()->subReal($x);
159
    }
160
161
    /**
162
     * {@inheritdoc}
163
     */
164
    public function subDecimal(Decimal $x, $scale = null)
165
    {
166
        return $this->toDecimal()->subDecimal($x, $scale);
167
    }
168
169
    /**
170
     * {@inheritdoc}
171
     */
172
    protected function invertedMult(Number $x)
173
    {
174
        return $x->multInteger($this);
175
    }
176
177
    /**
178
     * {@inheritdoc}
179
     */
180
    public function multInteger(Integer $x)
181
    {
182
        return new static($this->toNative() * $x->toNative());
183
    }
184
185
    /**
186
     * {@inheritdoc}
187
     */
188
    public function multReal(Real $x)
189
    {
190
        return $this->toReal()->multReal($x);
191
    }
192
193
    /**
194
     * {@inheritdoc}
195
     */
196
    public function multDecimal(Decimal $x, $scale = null)
197
    {
198
        return $this->toDecimal()->multDecimal($x, $scale);
199
    }
200
201
    /**
202
     * {@inheritdoc}
203
     */
204
    protected function invertedDiv(Number $x)
205
    {
206
        return $x->divInteger($this);
207
    }
208
209
    /**
210
     * {@inheritdoc}
211
     */
212 View Code Duplication
    public function divInteger(Integer $x)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
213
    {
214
        $value = $this->divSpecialCases($x);
215
        if ($value !== null) {
216
            return $value;
217
        }
218
219
        return Real::fromNative($this->toNative() / $x->toNative());
220
    }
221
222
    /**
223
     * {@inheritdoc}
224
     */
225
    public function divReal(Real $x)
226
    {
227
        return $this->toReal()->divReal($x);
228
    }
229
230
    /**
231
     * {@inheritdoc}
232
     */
233
    public function divDecimal(Decimal $x, $scale = null)
234
    {
235
        return $this->toDecimal()->divDecimal($x, $scale);
236
    }
237
238
    /**
239
     * {@inheritdoc}
240
     */
241
    protected function invertedPow(Number $x)
242
    {
243
        return $x->powInteger($this);
244
    }
245
246
    /**
247
     * @param int $x
248
     *
249
     * @return Number
250
     */
251
    public function powInteger(Integer $x)
252
    {
253
        return new static(\pow($this->toNative(), $x->toNative()));
254
    }
255
256
    /**
257
     * {@inheritdoc}
258
     */
259
    public function powReal(Real $x)
260
    {
261
        return $this->toReal()->powReal($x);
262
    }
263
264
    /**
265
     * {@inheritdoc}
266
     */
267
    public function powDecimal(Decimal $x, $scale = null)
268
    {
269
        return $this->toDecimal()->powDecimal($x, $scale);
270
    }
271
272
    /**
273
     * {@inheritdoc}
274
     */
275
    public function sqrt($scale = null)
276
    {
277
        return $this->toReal()->sqrt($scale);
278
    }
279
280
    /**
281
     * @return \Cubiche\Domain\System\Integer
282
     */
283
    public function inc()
284
    {
285
        return new static($this->toNative() + 1);
286
    }
287
288
    /**
289
     * @return \Cubiche\Domain\System\Integer
290
     */
291
    public function dec()
292
    {
293
        return new static($this->toNative() - 1);
294
    }
295
296
    /**
297
     * @param int $x
298
     *
299
     * @return \Cubiche\Domain\System\Integer
300
     */
301
    public function mod(Integer $x)
302
    {
303
        return new static($this->toNative() % $x->toNative());
304
    }
305
306
    /**
307
     * @return bool
308
     */
309
    public function isEven()
310
    {
311
        return $this->mod(self::fromNative(2))->isZero();
312
    }
313
314
    /**
315
     * @return bool
316
     */
317
    public function isOdd()
318
    {
319
        return !$this->isEven();
320
    }
321
}
322