Code Duplication    Length = 14-16 lines in 2 locations

src/Js/Js.php 1 location

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

src/Card/Card.php 1 location

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