Passed
Push — master ( f8b368...4df760 )
by Martin
05:42
created

CustomerBankAccount   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A removeMandate() 0 3 1
A fromArray() 0 8 3
A addMandate() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
namespace Lendable\GoCardlessEnterpriseBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
class CustomerBankAccount extends \Lendable\GoCardlessEnterprise\Model\CustomerBankAccount
8
{
9
    public function __construct()
10
    {
11
        $this->mandates = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new Doctrine\Common\Collections\ArrayCollection() of type Doctrine\Common\Collections\ArrayCollection is incompatible with the declared type Lendable\GoCardlessEnterprise\Model\Mandate[] of property $mandates.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
12
    }
13
14
    /**
15
     * @param Mandate $mandate
16
     */
17
    public function addMandate(Mandate $mandate)
18
    {
19
        $this->mandates[] = $mandate;
20
        $mandate->setCustomerBankAccount($this);
21
    }
22
23
    /**
24
     * @param Mandate $mandate
25
     */
26
    public function removeMandate(Mandate $mandate)
27
    {
28
        $this->mandates->removeElement($mandate);
29
    }
30
31
    public function fromArray($data)
32
    {
33
        parent::fromArray($data);
34
        if (array_key_exists('account_number_ending', $data) && !$this->getAccountNumber()) {
35
            $prefix = str_repeat('*', max(0, 8 - strlen($data['account_number_ending'])));
36
            $this->setAccountNumber($prefix.$data['account_number_ending']);
37
        }
38
        $this->setCreatedAt(new \DateTime($this->getCreatedAt()));
0 ignored issues
show
Bug introduced by
new DateTime($this->getCreatedAt()) of type DateTime is incompatible with the type string expected by parameter $createdAt of Lendable\GoCardlessEnter...l\Model::setCreatedAt(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        $this->setCreatedAt(/** @scrutinizer ignore-type */ new \DateTime($this->getCreatedAt()));
Loading history...
39
    }
40
}
41