BillPayment   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 5 5 1
A validate() 5 5 1

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
namespace WeDevBr\Bankly;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use WeDevBr\Bankly\Validators\BillPaymentValidator;
7
8
/**
9
 * BillPayment class
10
 *
11
 * PHP version 7.3|7.4|8.0
12
 *
13
 * @author    WeDev Brasil Team <[email protected]>
14
 * @author    Rafael Teixeira <[email protected]>
15
 * @copyright 2020 We Dev Tecnologia Ltda
16
 * @link      https://github.com/wedevBr/bankly-laravel/
17
 */
18 View Code Duplication
class BillPayment extends \stdClass implements Arrayable
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
19
{
20
    public $amount;
21
    public $bankBranch;
22
    public $bankAccount;
23
    public $description;
24
    public $id;
25
26
    /**
27
     * This validate and return an array
28
     * @return array
29
     */
30
    public function toArray(): array
31
    {
32
        $this->validate();
33
        return (array) $this;
34
    }
35
36
    /**
37
     * This function validate a bill payment
38
     */
39
    public function validate()
40
    {
41
        $validator = new BillPaymentValidator($this);
42
        $validator->validate();
43
    }
44
}
45