Code Duplication    Length = 15-16 lines in 2 locations

src/Js/Js.php 1 location

@@ 103-117 (lines=15) @@
100
     *
101
     * @return string
102
     */
103
    public function ticket($forceRefresh = false)
104
    {
105
        $key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId();
106
        $ticket = $this->getCache()->fetch($key);
107
108
        if (!$forceRefresh && !empty($ticket)) {
109
            return $ticket;
110
        }
111
112
        $result = $this->parseJSON('get', [self::API_TICKET, ['type' => 'jsapi']]);
113
114
        $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500);
115
116
        return $result['ticket'];
117
    }
118
119
    /**
120
     * Build signature.

src/Card/Card.php 1 location

@@ 169-184 (lines=16) @@
166
     *
167
     * @return string $apiTicket
168
     */
169
    public function getAPITicket($refresh = false)
170
    {
171
        $key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId();
172
173
        $ticket = $this->getCache()->fetch($key);
174
175
        if (!$ticket || $refresh) {
176
            $result = $this->parseJSON('get', [self::API_GET_CARD_TICKET, ['type' => 'wx_card']]);
177
178
            $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500);
179
180
            return $result['ticket'];
181
        }
182
183
        return $ticket;
184
    }
185
186
    /**
187
     * 微信卡券:JSAPI 卡券发放.