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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 94.74%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 41
ccs 18
cts 19
cp 0.9474
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getAmount() 0 26 5
A isSuccessful() 0 8 1
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