Bankcard   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getDefaultProvider() 0 4 1
A provider() 0 4 1
A __call() 0 4 1
1
<?php
2
3
4
namespace Sco\Bankcard;
5
6
use Sco\Bankcard\Contracts\Factory as FactoryContract;
7
use Sco\Bankcard\Contracts\Provider as ProviderContract;
8
use Sco\Bankcard\Providers\AlipayProvider;
9
10
/**
11
 * @method Contracts\Info info(string $cardNo)
12
 */
13
class Bankcard implements FactoryContract
14
{
15
    /**
16
     * @var \Sco\Bankcard\Contracts\Provider
17
     */
18
    protected $provider;
19
20
    public function __construct(ProviderContract $provider = null)
21
    {
22
        $this->provider = $provider ?: $this->getDefaultProvider();
23
    }
24
25
    protected function getDefaultProvider()
26
    {
27
        return new AlipayProvider();
28
    }
29
30
    public function provider()
31
    {
32
        return $this->provider;
33
    }
34
35
    public function __call($method, $parameters)
36
    {
37
        return call_user_func_array([$this->provider(), $method], $parameters);
38
    }
39
}
40