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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 5
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getAmount() 0 22 4
A isSuccessful() 0 4 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
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