Bank   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isHandled() 0 4 1
A nameOfNumber() 0 4 1
A ofNumber() 0 7 1
1
<?php
2
3
namespace SmartCNAB\Support;
4
5
/**
6
 * Bank support class.
7
 */
8
class Bank
9
{
10
    /**
11
     * Bank numbers constants.
12
     */
13
    const BANCO_DO_BRASIL = 1;
14
    const BRADESCO = 237;
15
    const CAIXA = 104;
16
    const ITAU = 341;
17
    const SANTANDER = 33;
18
    const SICOOB = 756;
19
20
    /**
21
     * Map for bank numbers and names.
22
     *
23
     * @var array
24
     */
25
    protected static $banksMap = [
26
        self::BANCO_DO_BRASIL => 'BancoDoBrasil',
27
        self::BRADESCO => 'Bradesco',
28
        self::CAIXA => 'Caixa',
29
        self::ITAU => 'Itau',
30
        self::SANTANDER => 'Santander',
31
        self::SICOOB => 'SICOOB',
32
    ];
33
34
    /**
35
     * Check if the received bank number is handled.
36
     *
37
     * @param  mixed  $number
38
     * @return boolean
39
     */
40
    public static function isHandled($number)
41
    {
42
        return ! empty(static::$banksMap[$number]);
43
    }
44
45
    /**
46
     * Return the name of received bank number.
47
     *
48
     * @param  mixed  $number
49
     * @return boolean
50
     */
51
    public static function nameOfNumber($number)
52
    {
53
        return static::$banksMap[$number];
54
    }
55
56
    /**
57
     * Return a bank support instance of received bank number.
58
     *
59
     * @param  mixed  $number
60
     * @return \SmartCNAB\Contracts\Support\BankSupportInterface
61
     */
62
    public static function ofNumber($number)
63
    {
64
        $name = static::nameOfNumber($number);
65
        $class = "\SmartCNAB\Support\Bank\\{$name}";
66
67
        return new $class();
68
    }
69
}
70