Code Duplication    Length = 22-24 lines in 2 locations

src/Wechat/Shop/Shelf.php 2 locations

@@ 46-69 (lines=24) @@
43
     * @return int
44
     * @throws ShopsException
45
     */
46
    public function add($shelfData,$shelfBanner,$shelfName)
47
    {
48
49
        if (is_callable($shelfData)) {
50
            $shelf = call_user_func($shelfData, new ShelfData());
51
            if (!($shelf instanceof ShelfData)) throw new ShopsException('必须返回 Shop\Data\Shelf class');
52
            $shelfData = $shelf->toArray();
53
        }
54
55
        //todo 判断出bug
56
        //if (!is_array($shelfData)) throw new ShopsException('$shelfData 必须是数组');
57
58
        $this->response = $this->http->jsonPost(self::API_ADD,array(
59
            'shelf_data' => array(
60
                'module_infos'=>$shelfData,
61
            ),
62
            'shelf_banner'=>$shelfBanner,
63
            'shelf_name'=>$shelfName
64
        ));
65
66
67
        return $this->getResponse();
68
69
    }
70
71
    /**
72
     * 删除货架
@@ 95-116 (lines=22) @@
92
     * @return bool
93
     * @throws ShopsException
94
     */
95
    public function update($shelfData,$shelfId,$shelfBanner,$shelfName)
96
    {
97
        if (is_callable($shelfData)) {
98
            $shelf = call_user_func($shelfData, new ShelfData());
99
            if (!($shelf instanceof ShelfData)) throw new ShopsException('必须返回 Shop\Data\Shelf class');
100
            $shelfData = $shelf->toArray();
101
        }
102
103
        //todo 判断出bug
104
        //if (!is_array($shelfData)) throw new ShopsException('$shelfData 必须是数组');
105
106
        $this->response = $this->http->jsonPost(self::API_UPDATE,array(
107
            'shelf_id' => $shelfId,
108
            'shelf_data' => array(
109
                'module_infos'=>$shelfData,
110
            ),
111
            'shelf_banner'=>$shelfBanner,
112
            'shelf_name'=>$shelfName
113
        ));
114
115
        return $this->getResponse();
116
    }
117
118
    /**
119
     * 获取所有货架