@param $changeFreq

@return string|false
324089
public static function validate($changeFreq)
    {
        if (\in_array(\trim(\strtolower($changeFreq)), self::$changeFreqValid, true)) {
            return \htmlentities($changeFreq);
        }

        return false;
    }
1326191
function shift() {
        if(\count($this->queue) === 0) {
            return false;
        }
        
        $item = \array_shift($this->queue);
        
        $this->get()->then(function ($data) {
            $data['remaining']--;
            
            return $this->set($data);
        })->done(null, array($this->api->client, 'handlePromiseRejection'));
        
        return $item;
    }
1373943
public function syncNewUsersAction($req)
    {
        if ($this->isPhpunit()) {
            return $this->suc('单元测试下,不执行同步');
        }

        // 1. 初始化数据

        // 本次同步成功的用户数
        $syncCount = 0;

        // 本次要同步的用户数
        $num = $req['num'] ?: 30;

        $api = wei()->wechatAccount->getCurrentAccount()->createApiService();

        // 2. 取出待同步的用户
        $syncUsers = wei()->db('wechatSyncUsers')->desc('id')->limit($num)->fetchAll();
        if (!$syncUsers) {
            return $this->suc('同步完成,没有新用户');
        }
        /** @var \Miaoxing\Plugin\Service\User $users */
        $users = wei()->user()->findAll(['id' => wei()->coll->column($syncUsers, 'id')]);

        // 3. 同步用户
        foreach ($users as $user) {
            $ret = wei()->wechatAccount->syncUser($user, $api);
            if ($ret['code'] === 1) {
                ++$syncCount;
            }
            // 删除已同步的记录
            wei()->db->delete('wechatSyncUsers', ['id' => $user['id']]);
        }

        // 4. 返回同步结果
        return $this->suc([
            'total' => $users->length(),
            'syncCount' => $syncCount,
        ]);
    }
1105930
public function setChangefreq($changefreq = null)
    {
        $frequencies = [
            self::CHANGEFREQ_ALWAYS,
            self::CHANGEFREQ_HOURLY,
            self::CHANGEFREQ_DAILY,
            self::CHANGEFREQ_WEEKLY,
            self::CHANGEFREQ_MONTHLY,
            self::CHANGEFREQ_YEARLY,
            self::CHANGEFREQ_NEVER,
            null,
        ];
        if (!in_array($changefreq, $frequencies)) {
            throw new \RuntimeException(
                sprintf(
                    'The value "%s" is not supported by the option changefreq. See http://www.sitemaps.org/protocol.html#xmlTagDefinitions',
                    $changefreq
                )
            );
        }

        $this->changefreq = $changefreq;

        return $this;
    }
952711
private function parseUnits($diff, $allowAlmost = false)
	{
		if (empty($diff))
		{
			return '';
		}

		$isAlmost = false;
		$string = array();

		foreach ($diff as $time)
		{
			if ($allowAlmost)
			{
				$isAlmost = $this->isAlmost($time);
			}

			$string[] = $this->translator->choice($time['unit'], $time['amount']);
		}

		$parsed = $string[0];

		// Add 'and' separator
		if (count($string) > 1)
		{
			$theLastOne = $string[count($string) - 1];
			unset($string[count($string) - 1]);

			$and = $this->translator->get('and');
			$parsed = sprintf('%s %s %s', implode(', ', $string), $and, $theLastOne);
		}

		if ($isAlmost)
		{
			$parsed = $this->translator->get('almost', array('time' => $parsed));
		}

		return $parsed;
	}
630636
private function requestsMatch($vary, $r1, $r2)
    {
        if ($vary) {
            foreach (explode(',', $vary) as $header) {
                $key = trim(strtolower($header));
                $v1 = isset($r1[$key]) ? $r1[$key] : null;
                $v2 = isset($r2[$key]) ? $r2[$key] : null;
                if ($v1 !== $v2) {
                    return false;
                }
            }
        }

        return true;
    }
151205
private function _sync_clock_diff( $diff = false ) {
			$this->_logger->entrance();

			// Sync clock and store.
			$new_clock_diff = ( false === $diff ) ?
				Freemius_Api_WordPress::FindClockDiff() :
				$diff;

			if ( $new_clock_diff === self::$_clock_diff ) {
				return false;
			}

			self::$_clock_diff = $new_clock_diff;

			// Update API clock's diff.
			Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );

			// Store new clock diff in storage.
			self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );

			return $new_clock_diff;
		}
555034
private function getEventExchangeName($messageFqcn)
    {
        $messageFqcn = trim($messageFqcn, '\\');
        $pos = strrpos($messageFqcn, '\\');
        if ($pos !== false) {
            $messageFqcn = substr_replace($messageFqcn, ':', $pos, 1);
        }
        return str_replace('\\', '.', $messageFqcn);
    }
906545
private static function lookupRequestedChange()
    {
        // Only run if the query param is present
        if (!$change_id = request(Change::QUERY_KEY)) {
            return;
        }

        // Don't execute for classes that result in recusirve queries when the
        // Change model gets built below
        $class = get_called_class();
        if (in_array($class, [Change::class, Admin::class, Image::class])) {
            return;
        }

        // Check whether the referenced Change is for this class
        $change = Change::find($change_id);
        if ($class == $change->model) {
            return $change;
        }
    }
644398
public function getRate($fromCurrency, $toCurrency)
    {
        if ($fromCurrency === $toCurrency) {
            return 1;
        }

        $currencyString = "{$fromCurrency}-{$toCurrency}";
        if (!isset($this->rates[$currencyString])) {
            throw new NoExchangeRateException(sprintf(
                'Cannot convert %s to %s, no exchange rate found.',
                $fromCurrency,
                $toCurrency
            ));
        }

        return $this->rates[$currencyString];
    }
256267
public function add($loc, $lastmod = null, $changefreq = null, $priority = null)
    {
        $loc     = $this->escapeString($loc);
        $lastmod = !is_null($lastmod) ? $this->formatDate($lastmod) : null;

        return $this->addUrlToDocument(compact('loc', 'lastmod', 'changefreq', 'priority'));
    }
477233
protected function getChangeSetResource(ChangeSet $changeSet, $sync = false)
    {
        $stateLabel = sprintf(
            '<span class="campaign-status campaign-status--%s"></span>%s',
            $changeSet->State,
            $changeSet->getStateLabel()
        );

        $hal = [
            '_links' => [
                'self' => [
                    'href' => $this->SetLink($changeSet->ID)
                ]
            ],
            'ID' => $changeSet->ID,
            'Name' => $changeSet->Name,
            'Created' => $changeSet->Created,
            'LastEdited' => $changeSet->LastEdited,
            'State' => $changeSet->State,
            'StateLabel' => [ 'html' => $stateLabel ],
            'IsInferred' => $changeSet->IsInferred,
            'canEdit' => $changeSet->canEdit(),
            'canPublish' => false,
            '_embedded' => ['items' => []],
            'placeholderGroups' => $this->getPlaceholderGroups(),
        ];

        // Before presenting the changeset to the client,
        // synchronise it with new changes.
        try {
            if ($sync) {
                $changeSet->sync();
            }
            $hal['PublishedLabel'] = $changeSet->getPublishedLabel() ?: '-';
            $hal['Details'] = $changeSet->getDetails();
            $hal['canPublish'] = $changeSet->canPublish() && $changeSet->hasChanges();

            foreach ($changeSet->Changes() as $changeSetItem) {
                if (!$changeSetItem) {
                    continue;
                }

                /** @var ChangesetItem $changeSetItem */
                $resource = $this->getChangeSetItemResource($changeSetItem);
                if (!empty($resource)) {
                    $hal['_embedded']['items'][] = $resource;
                }
            }

        // An unexpected data exception means that the database is corrupt
        } catch (UnexpectedDataException $e) {
            $hal['PublishedLabel'] = '-';
            $hal['Details'] = 'Corrupt database! ' . $e->getMessage();
            $hal['canPublish'] = false;
        }
        return $hal;
    }
60896
public function getCurrency($forceDefault = true)
    {
        $currency = $this->get("thelia.current.currency");

        if (null === $currency && $forceDefault) {
            $currency = Currency::getDefaultCurrency();
        }

        return $currency;
    }
1255804
public function getModifyColumnDDL(ColumnDiff $columnDiff)
    {
        $ret = '';
        $changedProperties = $columnDiff->getChangedProperties();

        $fromColumn = $columnDiff->getFromColumn();
        $toColumn = clone $columnDiff->getToColumn();

        $fromTable = $fromColumn->getTable();
        $table = $toColumn->getTable();

        $colName = $this->quoteIdentifier($toColumn->getName());

        $pattern = "
ALTER TABLE %s ALTER COLUMN %s;
";

        if (isset($changedProperties['autoIncrement'])) {
            $tableName = $table->getName();
            $colPlainName = $toColumn->getName();
            $seqName = "{$tableName}_{$colPlainName}_seq";

            if ($toColumn->isAutoIncrement() && $table && $table->getIdMethodParameters() == null) {

                $defaultValue = "nextval('$seqName'::regclass)";
                $toColumn->setDefaultValue($defaultValue);
                $changedProperties['defaultValueValue'] = [null, $defaultValue];

                //add sequence
                if (!$fromTable->getDatabase()->hasSequence($seqName)) {
                    $this->createOrDropSequences .= sprintf("
CREATE SEQUENCE %s;
",
                        $seqName
                    );
                    $fromTable->getDatabase()->addSequence($seqName);
                }
            }

            if (!$toColumn->isAutoIncrement() && $fromColumn->isAutoIncrement()) {
                $changedProperties['defaultValueValue'] = [$fromColumn->getDefaultValueString(), null];
                $toColumn->setDefaultValue(null);

                //remove sequence
                if ($fromTable->getDatabase()->hasSequence($seqName)) {
                    $this->createOrDropSequences .= sprintf("
DROP SEQUENCE %s CASCADE;
",
                        $seqName
                    );
                    $fromTable->getDatabase()->removeSequence($seqName);
                }
            }
        }

        if (isset($changedProperties['size']) || isset($changedProperties['type']) || isset($changedProperties['sqlType']) || isset($changedProperties['scale'])) {

            $sqlType = $toColumn->getDomain()->getSqlType();

            if ($this->hasSize($sqlType) && $toColumn->isDefaultSqlType($this)) {
                if ($this->isNumber($sqlType)) {
                    if ('NUMERIC' === strtoupper($sqlType)) {
                        $sqlType .= $toColumn->getSizeDefinition();
                    }
                } else {
                    $sqlType .= $toColumn->getSizeDefinition();
                }
            }

            if ($using = $this->getUsingCast($fromColumn, $toColumn)) {
                $sqlType .= $using;
            }
            $ret .= sprintf($pattern,
                $this->quoteIdentifier($table->getName()),
                $colName . ' TYPE ' . $sqlType
            );
        }

        if (isset($changedProperties['defaultValueValue'])) {
            $property = $changedProperties['defaultValueValue'];
            if ($property[0] !== null && $property[1] === null) {
                $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . ' DROP DEFAULT');
            } else {
                $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . ' SET ' . $this->getColumnDefaultValueDDL($toColumn));
            }
        }

        if (isset($changedProperties['notNull'])) {
            $property = $changedProperties['notNull'];
            $notNull = ' DROP NOT NULL';
            if ($property[1]) {
                $notNull = ' SET NOT NULL';
            }
            $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . $notNull);
        }

        return $ret;
    }
34771
public function isValid($value)
    {
        $this->_setValue($value);

        if (!is_string($value)) {
            return false;
        }

        if (!in_array($value, $this->_changeFreqs, true)) {
            $this->_error();
            return false;
        }

        return true;
    }
861393
public function getFrequencyString(bool $upperCase = false) :string
    {
        switch ($this->frequency) {
            case 7:
                $str = 'weekly';
                break;
            case 14:
                $str = 'bi-weekly';
                break;
            case 30:
                $str = 'monthly';
                break;
            case 91:
                $str = 'quartaly';
                break;
            default:
                $str = '';
                break;
        }

        if ($upperCase) {
            $str = strtoupper($str);
            $str = str_replace('-', '_', $str);
        }

        return $str;
    }
58425
private function _ensureExchangeForQueue($queue)
    {
        $serverId = $this->_getQueueServerId($queue);
        $server   = &$this->servers[$serverId];
        
        $reason       = self::REASON_MAIN;
        $exchangeName = self::DEFAULT_EXCHANGE;
        
        if (isset($server[self::SERVER_EXCHANGES][$reason][$exchangeName])) {
            return $server[self::SERVER_EXCHANGES][$reason][$exchangeName];
        }
        
        $this->_serverEnsureConnection($server, $reason);
        $this->_serverEnsureChannel($server, self::REASON_MAIN);
        $exchangeObj = $this->_setupExchange($server, self::REASON_MAIN, $exchangeName);
        
        $server[self::SERVER_EXCHANGES][$reason][$exchangeName] = $exchangeObj;
        
        return $exchangeObj;
    }