Test Failed
Push — master ( 020fe5...ff9a8e )
by
01:58
created

Source   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 22.73 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 5
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCreateData() 5 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the PhpMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
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
declare(strict_types=1);
13
14
namespace PhpMob\Omise\Domain;
15
16
use PhpMob\Omise\Country;
17
use PhpMob\Omise\Currency;
18
use PhpMob\Omise\Exception\InvalidRequestArgumentException;
19
use PhpMob\Omise\Model;
20
21
/**
22
 * @author Ishmael Doss <[email protected]>
23
 *
24
 * @property string object
25
 * @property string id
26
 * @property string type
27
 * @property string flow
28
 * @property integer amount
29
 * @property string currency
30
 */
31
class Source extends Model
32
{
33
    /**
34
     * @param string $countryCode
35
     *
36
     * @return array
37
     */
38
    public function getCreateData($countryCode = Country::TH)
39
    {
40 View Code Duplication
        if (!in_array($this->currency, Currency::getSupporteds($countryCode))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
41
            throw new InvalidRequestArgumentException(
42
                sprintf('The currency `%s` is not supported in your country `%s`.', $this->currency, $countryCode)
43
            );
44
        }
45
46
        return [
47
            'amount' => $this->amount * Currency::getDivisionOffset($this->currency),
48
            'currency' => $this->currency,
49
            'type' => $this->type,
50
        ];
51
    }
52
}
53