DouDian   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setShopId() 0 5 1
A getShopId() 0 3 1
A __get() 0 8 2
1
<?php
2
3
namespace Abbotton\DouDian;
4
5
use Abbotton\DouDian\Api\AfterSale;
6
use Abbotton\DouDian\Api\Alliance;
7
use Abbotton\DouDian\Api\AntiSpam;
8
use Abbotton\DouDian\Api\Bats;
9
use Abbotton\DouDian\Api\Brand;
10
use Abbotton\DouDian\Api\BuyIn;
11
use Abbotton\DouDian\Api\Coupons;
12
use Abbotton\DouDian\Api\CrossBorder;
13
use Abbotton\DouDian\Api\DutyFree;
14
use Abbotton\DouDian\Api\FreightTemplate;
15
use Abbotton\DouDian\Api\Iop;
16
use Abbotton\DouDian\Api\Logistics;
17
use Abbotton\DouDian\Api\Material;
18
use Abbotton\DouDian\Api\Member;
19
use Abbotton\DouDian\Api\OpenCloud;
20
use Abbotton\DouDian\Api\Order;
21
use Abbotton\DouDian\Api\OrderCode;
22
use Abbotton\DouDian\Api\Product;
23
use Abbotton\DouDian\Api\Recycle;
24
use Abbotton\DouDian\Api\Security;
25
use Abbotton\DouDian\Api\Shop;
26
use Abbotton\DouDian\Api\Sms;
27
use Abbotton\DouDian\Api\Spu;
28
use Abbotton\DouDian\Api\Storage;
29
use Abbotton\DouDian\Api\SupplyChain;
30
use Abbotton\DouDian\Api\Token;
31
use Abbotton\DouDian\Api\Topup;
32
use Abbotton\DouDian\Api\WareHouse;
33
use Abbotton\DouDian\Api\Yunc;
34
use Exception;
35
use Illuminate\Support\Str;
36
37
/**
38
 * Class DouDian.
39
 *
40
 * @property AfterSale   $afterSale
41
 * @property Alliance    $alliance
42
 * @property AntiSpam    $antiSpam
43
 * @property Bats        $bats
44
 * @property Brand       $brand
45
 * @property BuyIn       $buyIn
46
 * @property Coupons     $coupons
47
 * @property CrossBorder $crossBorder
48
 * @property DutyFree    $dutyFree
49
 * @property FreightTemplate    $freightTemplate
50
 * @property Logistics   $logistics
51
 * @property Iop         $iop
52
 * @property Material    $material
53
 * @property Member      $member
54
 * @property OpenCloud   $openCloud
55
 * @property Order       $order
56
 * @property OrderCode   $orderCode
57
 * @property Product     $product
58
 * @property Recycle     $recycle
59
 * @property Security    $security
60
 * @property Shop        $shop
61
 * @property Sms         $sms
62
 * @property Storage     $storage
63
 * @property SupplyChain $supplyChain
64
 * @property Spu         $spu
65
 * @property Token       $token
66
 * @property Topup       $topup
67
 * @property WareHouse   $wareHouse
68
 * @property Yunc        $yunc
69
 */
70
class DouDian
71
{
72
    private $config;
73
    private $shop_id = null;
74
75
    public function __construct(array $config = [])
76
    {
77
        $this->config = $config;
78
    }
79
80
    public function __get($class)
81
    {
82
        $class = '\\Abbotton\\DouDian\\Api\\'.Str::ucfirst($class);
83
        if (! class_exists($class)) {
84
            throw new Exception($class.', Not found', 404);
85
        }
86
87
        return new $class($this->config, $this->shop_id);
88
    }
89
90
    /**
91
     * 设定店铺ID.
92
     *
93
     * @param int $shopId
94
     *
95
     * @return $this
96
     */
97
    public function setShopId(int $shopId): self
98
    {
99
        $this->shop_id = $shopId;
100
101
        return $this;
102
    }
103
104
    /**
105
     * 获取店铺ID.
106
     *
107
     * @return mixed|null
108
     */
109
    public function getShopId()
110
    {
111
        return $this->shop_id;
112
    }
113
}
114