original_string: public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
      {
          $cacheKey = sprintf('easywechat.basic_service.jssdk.ticket.%s.%s', $type, $this->getAppId());
  
          if (!$refresh && $this->getCache()->has($cacheKey)) {
              return $this->getCache()->get($cacheKey);
          }
  
          $result = $this->castResponseToType(
              $this->requestRaw($this->ticketEndpoint, 'GET', ['query' => ['type' => $type]]),
              'array'
          );
  
          $this->getCache()->set($cacheKey, $result, $result['expires_in'] - 500);
  
          if (!$this->getCache()->has($cacheKey)) {
              throw new RuntimeException('Failed to cache jssdk ticket.');
          }
  
          return $result;
      }
code: public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
      {
          $cacheKey = sprintf('easywechat.basic_service.jssdk.ticket.%s.%s', $type, $this->getAppId());
  
          if (!$refresh && $this->getCache()->has($cacheKey)) {
              return $this->getCache()->get($cacheKey);
          }
  
          $result = $this->castResponseToType(
              $this->requestRaw($this->ticketEndpoint, 'GET', ['query' => ['type' => $type]]),
              'array'
          );
  
          $this->getCache()->set($cacheKey, $result, $result['expires_in'] - 500);
  
          if (!$this->getCache()->has($cacheKey)) {
              throw new RuntimeException('Failed to cache jssdk ticket.');
          }
  
          return $result;
      }
code_tokens: public function getTicket ( bool $ refresh = false , string $ type = 'jsapi' ) : array { $ cacheKey = sprintf ( 'easywechat.basic_service.jssdk.ticket.%s.%s' , $ type , $ this -> getAppId ( ) ) ; if ( ! $ refresh && $ this -> getCache ( ) -> has ( $ cacheKey ) ) { return $ this -> getCache ( ) -> get ( $ cacheKey ) ; } $ result = $ this -> castResponseToType ( $ this -> requestRaw ( $ this -> ticketEndpoint , 'GET' , [ 'query' => [ 'type' => $ type ] ] ) , 'array' ) ; $ this -> getCache ( ) -> set ( $ cacheKey , $ result , $ result [ 'expires_in' ] - 500 ) ; if ( ! $ this -> getCache ( ) -> has ( $ cacheKey ) ) { throw new RuntimeException ( 'Failed to cache jssdk ticket.' ) ; } return $ result ; }
docstring: Get js ticket.
  
  @param bool   $refresh
  @param string $type
  
  @return array|null
  
  @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  @throws \Psr\SimpleCache\InvalidArgumentException
  @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
docstring_tokens: Get js ticket .