@param bool $refresh

@return mixed
@throws \Exception
166471
public function getUDN($refresh = false)
    {
        if ($refresh === false) {
            $device = Discovery::lookupDevice('ip', $this->ip);
            if (isset($device['UDN'])) {
                return $device['UDN'];
            }
        }

        $rs = $this->info();

        if (is_array($rs) && isset($rs['root'])) {
            return $rs['root']['device']['UDN'];
        }

        throw new \Exception('UDN not found for device with ip address ' . $this->ip);
    }
884444
public function getAccessToken($refresh = false)
    {
        if ($this->_auth) {
            return $this->_auth->getToken($refresh)->access_token;
        } else {
            return null;
        }
    }
187779
public function getShopOrderStatusCodeObject($bRefresh = false)
    {
        if (true === $bRefresh) {
            $this->shopOrderStatusCodeObject = null;
        }
        if (null === $this->shopOrderStatusCodeObject) {
            $this->shopOrderStatusCodeObject = TdbShopOrderStatusCode::GetNewInstance();
            $aFilter = array(
                'shop_id' => $this->getOrder()->fieldShopId,
                'system_name' => $this->getShopOrderStatusCode(),
            );
            if (false === $this->shopOrderStatusCodeObject->LoadFromFields($aFilter)) {
                $shopId = $this->getOrder()->fieldShopId;
                $e = new TPkgShopOrderStatusException_OrderStatusCodeNotFound(
                    "no order status code in shop [{$shopId}] with system_name [{$this->getShopOrderStatusCode()}]",
                    array('orderStatus' => $this)
                );
                $e->setStatusCode($this->getShopOrderStatusCode())
                    ->setShopId($this->getOrder()->fieldShopId);
                throw $e;
            }
        }

        return $this->shopOrderStatusCodeObject;
    }
76857
protected function buildRouteMaps($refresh = false)
    {
        if ($this->routeMaps && !$this->debug && !$refresh) {
            return $this;
        }

        foreach ($this->routes as $key => $routeItem) {
            $this->routeMaps[$routeItem->getName()] = $key;
        }

        return $this;
    }
463740
public function isMobile($refresh = false)
    {
        if (empty($this->detection['device']) || $refresh) {
            $this->detectDevice($this->userAgent);
        }

        return $this->mobile;
    }
1319695
public function getTicket(bool $refresh = false, string $type = 'wx_card'): array
    {
        return parent::getTicket($refresh, $type);
    }
734498
protected function getCmd($refresh = false)
    {
        if (is_null($this->cmd) || $refresh) {
            $this->cmd = new Command();
        }
        
        return $this->cmd;
    }
612950
public function getTokens($refresh = false)
    {
        if (! $this->_tokens || $refresh) {
            if ($refresh) {
                $this->_firstToken = null;
            }
            $this->_tokens       = array();
            $this->_activeTokens = array();
            $tokenSelect = $this->tracker->getTokenSelect();
            $tokenSelect->andReceptionCodes()
                ->forRespondentTrack($this->_respTrackId);

            $tokenRows = $tokenSelect->fetchAll();
            $prevToken = null;
            foreach ($tokenRows as $tokenData) {

                $token = $this->tracker->getToken($tokenData);

                $this->_tokens[$token->getTokenId()] = $token;

                // While we are busy, set this
                if ($token->hasSuccesCode()) {
                    $this->_activeTokens[$token->getRoundId()] = $token;
                }

                // Link the tokens
                if ($prevToken) {
                    $prevToken->setNextToken($token);
                }
                $prevToken = $token;
            }
        }

        return $this->_tokens;
    }
1347085
public function refresh($forceForever = false, $resetClaims = false)
    {
        return $this->requireToken()->refresh($forceForever, $resetClaims);
    }
820871
protected function requestAccessToken($forceRefresh = false)
    {
        if (null === $this->accessToken) {
            $this->acquireAccessToken();
        } elseif ($this->accessToken->hasExpired() || $forceRefresh) {
            try {
                $this->refreshToken();
            } catch (ClientException $e) {
                if (400 != $e->getResponse()->getStatusCode()) {
                    throw $e;
                }

                $this->acquireAccessToken();
            }
        }
    }
1226618
public function hasRequiredSettings(bool $refresh = false): bool
    {
        $required = $this->getParsedRequiredProperties($refresh);

        if (!$this->allRequired && (empty($required) || $required === null)) {
            return true;
        }

        return $this->validateProperties($required);
    }
180079
public function getCollection($name, $refresh = false)
    {
        if ($refresh || !array_key_exists($name, $this->_collections)) {
            $this->_collections[$name] = $this->selectCollection($name);
        }

        return $this->_collections[$name];
    }
238301
public function getColumnDetails($refresh = false)
    {
        if (!$this->columnCache || $refresh) {
            $details = [];
            $table = $this->db->replacePrefix((string) $this->name);

            $query = $this->db->getQuery(true);
            $query->select([
                'column_name AS Field',
                'data_type AS Type',
                'is_nullable AS ' . $query->quote('Null'),
                'column_default AS ' . $query->quote('Default'),
                'character_maximum_length',
                'numeric_precision',
                'numeric_scale',
            ])->from('information_schema.columns')
                ->where('table_name = %q', $table);

            $fields = $this->db->prepare($query)->loadAll();

            $keys = $this->getIndexes();

            foreach ($fields as $field) {
                $field->Key = '';
                $field->Extra = '';

                // Type & Length
                $length = ((int) $field->character_maximum_length) > 0
                    ? $field->character_maximum_length
                    : null;

                if ($field->numeric_precision) {
                    $length = $field->numeric_precision;

                    if ($field->numeric_scale) {
                        $length .= ',' . $field->numeric_scale;
                    }
                }

                if ($length) {
                    $field->Type .= '(' . $length . ')';
                }

                // Default
                // Parse ('foo') as foo
                $field->Default = preg_replace(
                    "/(^(\(\(|\('|\(N'|\()|(('\)|(?<!\()\)\)|\))$))/i",
                    '',
                    $field->Default
                );

                $details[$field->Field] = $field;

                // Find key
                $index = null;

                foreach ($keys as $key) {
                    if ($key->Column_name == $field->Field) {
                        $index = $key;
                        break;
                    }
                }

                if ($index) {
                    if ($index->Is_primary) {
                        $field->Key = 'PRI';
                    } elseif (!$index->Non_unique) {
                        $field->Key = 'UNI';
                    } else {
                        $field->Key = 'MUL';
                    }

                    if ($index->is_identity) {
                        $field->Extra = 'auto_increment';
                    }
                }
            }

            $this->columnCache = $details;
        }

        return $this->columnCache;
    }
1354463
public function getFileCollection($refresh = false)
    {
        if ($refresh || !is_object($this->_fileCollection)) {
            $this->_fileCollection = Yii::createObject([
                'class' => 'yii\mongodb\Collection',
                'database' => $this->database,
                'name' => $this->name
            ]);
        }

        return $this->_fileCollection;
    }
591080
public function isRobot($refresh = false)
    {
        if (empty($this->detection['robot']) || $refresh) {
            $this->detectRobot($this->userAgent);
        }

        return $this->robot;
    }
1218206
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;
    }
894921
protected function getCache($key, $refresh, callable $fn)
    {
        if ($refresh || $this->isRefresh()) {
            $this->configCache->remove($key);
        }

        return $this->configCache->get($key, function () use ($fn) {
            return $fn();
        });
    }