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
Pull Request — master (#62)
by Jelte
04:52
created

AbstractPaymentResponse::getAmount()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 22
rs 8.9197
cc 4
eloc 12
nc 4
nop 0
1
<?php
2
/*
3
 * This file is part of the Marlon Ogone package.
4
 *
5
 * (c) Marlon BVBA <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Ogone;
12
13
abstract class AbstractPaymentResponse extends AbstractResponse implements PaymentResponse
14
{
15
    /**
16
     * @return int Amount in cents
17
     */
18
    public function getAmount()
19
    {
20
        $value = trim($this->parameters['AMOUNT']);
21
22
        $withoutDecimals = '#^\d*$#';
23
        $oneDecimal = '#^\d*\.\d$#';
24
        $twoDecimals = '#^\d*\.\d\d$#';
25
26
        if (preg_match($withoutDecimals, $value)) {
27
            return (int) ($value.'00');
28
        }
29
30
        if (preg_match($oneDecimal, $value)) {
31
            return (int) (str_replace('.', '', $value).'0');
32
        }
33
34
        if (preg_match($twoDecimals, $value)) {
35
            return (int) (str_replace('.', '', $value));
36
        }
37
38
        throw new \InvalidArgumentException("Not a valid currency amount");
39
    }
40
41
    public function isSuccessful()
42
    {
43
        return in_array($this->getParam('STATUS'), array(PaymentResponse::STATUS_AUTHORISED, PaymentResponse::STATUS_PAYMENT_REQUESTED));
44
    }
45
}
46