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 ( 70cfba...ddf1bf )
by Jelte
10:05 queued 07:35
created

AbstractPaymentResponse::getAmount()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5.009

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
ccs 13
cts 14
cp 0.9286
rs 8.439
cc 5
eloc 14
nc 5
nop 0
crap 5.009
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
use InvalidArgumentException;
14
15
abstract class AbstractPaymentResponse extends AbstractResponse implements PaymentResponse
16
{
17
    /**
18
     * @return int Amount in cents
19
     */
20 18
    public function getAmount()
21
    {
22 18
        if (!isset($this->parameters['AMOUNT'])) {
23
            throw new InvalidArgumentException('Parameter AMOUNT does not exist');
24
        }
25
26 18
        $value = trim($this->parameters['AMOUNT']);
27
28 18
        $withoutDecimals = '#^\d*$#';
29 18
        $oneDecimal = '#^\d*\.\d$#';
30 18
        $twoDecimals = '#^\d*\.\d\d$#';
31
32 18
        if (preg_match($withoutDecimals, $value)) {
33 3
            return (int) ($value.'00');
34
        }
35
36 15
        if (preg_match($oneDecimal, $value)) {
37 2
            return (int) (str_replace('.', '', $value).'0');
38
        }
39
40 13
        if (preg_match($twoDecimals, $value)) {
41 12
            return (int) (str_replace('.', '', $value));
42
        }
43
44 1
        throw new \InvalidArgumentException("Not a valid currency amount");
45
    }
46
47 2
    public function isSuccessful()
48
    {
49 2
        return in_array($this->getParam('STATUS'), array(
50 2
            PaymentResponse::STATUS_AUTHORISED,
51 2
            PaymentResponse::STATUS_PAYMENT_REQUESTED,
52
            PaymentResponse::STATUS_PAYMENT_BY_MERCHANT
53 2
        ));
54
    }
55
}
56