Returns cut down part of [[$summary]].

@param integer $limit
@return string
14547
public function getLimitedSummary( $limit = CoreGlobal::DISPLAY_TEXT_MEDIUM ) {

		$summary = $this->summary;

		if( strlen( $summary ) > $limit ) {

			$summary = substr( $summary, 0, $limit );
		}

		return HtmlPurifier::process( $summary );
	}
1215045
public function split($regex = '//u', $limit = -1){
		
		if(!\is_string($regex)){
			throw new \InvalidArgumentException('$regex is not a string');
		}
		
		if(!\is_numeric($limit)){
			throw new \InvalidArgumentException('$limit is not a number');
		}
		
		return \preg_split($regex, $this->_Value, $limit, \PREG_SPLIT_NO_EMPTY);
		
	}
464080
public function parseLimit($limit)
    {
        $limitStr = '';
        if (!empty($limit)) {
            $limit = explode(',', $limit);
            if (count($limit) > 1) {
                $limitStr = "(numrow>" . $limit[0] . ") AND (numrow<=" . ($limit[0] + $limit[1]) . ")";
            } else {
                $limitStr = "(numrow>0 AND numrow<=" . $limit[0] . ")";
            }

        }
        return $limitStr ? ' WHERE ' . $limitStr : '';
    }
572576
public function limit($limit = null)
    {
        if ($limit) {
            if ($limit < 0) {
                $this->items = array_slice($this->items, $limit, abs($limit));
            }
            else {
                $this->items = array_slice($this->items, 0, $limit);
            }
        }

        return $this;
    }
698903
public function createLimit($limit = null)
    {
        // 未指定
        if (!$limit) {
            return [];
        }

        // 如果是字符串,分解吧
        if (is_string($limit)) {
            // 去首尾空格
            $limit = trim($limit);

            // 尝试以空格区分
            if (strpos($limit, ' ')) {
                $limit = explode(' ', $limit);
                return [intval($limit[0]), intval($limit[1])];
            }

            // 尝试以逗号区分
            if (strpos($limit, ',')) {
                $limit = explode(',', $limit);
                return [intval($limit[0]), intval($limit[1])];
            }

            // 尝试以:区分
            if (strpos($limit, ':')) {
                $limit = explode(':', $limit);
                return [intval($limit[0]), intval($limit[1])];
            }

            // 没找到间隔符,只能假设只指定了长度
            return [0, intval($limit)];
        }

        // 如果是整数,好办,只指定了长度
        if (is_int($limit)) {
            return [0, intval($limit)];
        }

        // 分页参数 必须是空或0或字符串或数组
        if (!is_array($limit)) {
            trigger_error('分页参数必须是字符串或数组:' . json($limit), E_USER_ERROR);
        }

        return [intval($limit[0]), intval($limit[1])];
    }
167381
public function getFullUri()
    {
        $queryString = '';

        $params = array();
        if ($this->hasQuery()) {
            $params[] = $this->getQueryParam();
        }

        if ($this->hasOrderBy()) {
            $params[] = $this->getOrderByParam();
        }

        if ($this->hasSummarizeBy()) {
            $params[] = 'summarize-by=' . $this->getSummarizeBy();
        }

        if ($this->hasOffset()) {
            $params[] = 'offset=' . $this->getOffset();
        }

        if ($this->hasLimit()) {
            $params[] = 'limit=' . $this->getLimit();
        }

        if ($this->hasIncludeTotal()) {
            $params[] = 'include-total=' . $this->getIncludeTotalAsString();
        }

        if (!empty($params)) {
            $queryString = '?' . implode('&', $params);
        }

        return '/' . ltrim($this->getUri(), '/') . $queryString;
    }
462733
protected function getLimitQuery( $limits = array() )
	{
		if( is_array( $limits ) && count( $limits ) == 2 )
			$limits	= ' LIMIT '.$limits[0].', '.$limits[1];
		else if( is_int( $limits ) && $limits )
			$limits	= ' LIMIT 0, '.$limits;
		else
			$limits	= '';
		return $limits;
	}
1306052
public function getSummary()
    {
        if ($this->summary && strtolower(trim($this->summary)) != '{@inheritdoc}') {
            return $this->summary;
        }

        $parent = $this->getInheritedElement();
        if ($parent instanceof DescriptorAbstract) {
            return $parent->getSummary();
        }

        return $this->summary;
    }
738493
public function getAllDepartments($limit = CAKE_LDAP_SYNC_AD_LIMIT) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.value',
		];
		$blockExists = $this->hasField('block');
		if ($blockExists) {
			$fields[] = $this->alias . '.block';
		}
		$conditions = [];
		$order = [$this->alias . '.value' => 'asc'];
		$this->recursive = -1;

		return $this->find('all', compact('fields', 'conditions', 'order'));
	}
836014
public function truncate(int $maximum) : Text
    {
        return $this->pipe(
            function (string $value) use ($maximum) : string {
                return strlen($value) > $maximum
                    ? substr($value, 0, $maximum)
                    : $value;
            }
        );
    }
710697
public function get_description() {
        $allhelp = array();
        if ($this->aggregation != GRADE_AGGREGATE_SUM) {
            $aggrstrings = grade_helper::get_aggregation_strings();
            $allhelp[] = $aggrstrings[$this->aggregation];
        }

        if ($this->droplow && $this->can_apply_limit_rules()) {
            $allhelp[] = get_string('droplowestvalues', 'grades', $this->droplow);
        }
        if ($this->keephigh && $this->can_apply_limit_rules()) {
            $allhelp[] = get_string('keephighestvalues', 'grades', $this->keephigh);
        }
        if (!$this->aggregateonlygraded) {
            $allhelp[] = get_string('aggregatenotonlygraded', 'grades');
        }
        if ($allhelp) {
            return implode('. ', $allhelp) . '.';
        }
        return '';
    }
28642
public function getExcerpt($limit = 50, $more = '&hellip;')
    {
        $content = strip_tags($this->getContent());
        if (strlen($content) <= $limit) {
            return $content;
        }

        $content = mb_substr($content, 0, $limit);
        $content = mb_substr($content, 0, mb_strrpos($content, ' '));

        if (! empty($more)) {
            $content .= $more;
        }

        return $content;
    }
574423
public function getSummaryAttribute()
    {
        $excerpt = $this->excerpt;
        if (strlen(trim($excerpt))) {
            return $excerpt;
        }

        $more = '<!-- more -->';
        if (strpos($this->content_html, $more) !== false) {
            $parts = explode($more, $this->content_html);

            return array_get($parts, 0);
        }

        return Html::limit($this->content_html, 600);
    }
211162
public function limit($limit = null) {
		if (is_null($limit)) //remove options
			return $this->discard('query.limit');
	
		return $this->merge(['query.limit' => intval($limit)]);
	}
388495
public function getDescription(): string
    {
        if (!$this->minValue) {
            return __('must have a length lower than "%d"', $this->maxValue);
        }
        if (!$this->maxValue) {
            return __('must have a length greater than "%d"', $this->minValue);
        }
        if ($this->minValue === $this->maxValue) {
            return __('must have a length "%d"', $this->minValue);
        }
        return __('must have a length between "%d" and "%d"', $this->minValue, $this->maxValue);
    }
869996
protected function getLastSearchesResultSet($limit) : array
    {
        $queryBuilder = $this->getQueryBuilder();
        return $queryBuilder
            ->select('keywords')
            ->addSelectLiteral(
                $queryBuilder->expr()->max('tstamp','maxtstamp')
            )
            ->from($this->table)
            // There is no support for DISTINCT, a ->groupBy() has to be used instead.
            ->groupBy('keywords')
            ->orderBy('maxtstamp', 'DESC')
            ->setMaxResults($limit)->execute()->fetchAll();
    }
544367
public static function cutWords(string $string, int $limit = 25, string $append = '...'): string
    {
        preg_match('/^\s*+(?:\S++\s*+){1,' . $limit . '}/u', $string, $matches);
        if (!isset($matches[0]) || mb_strlen($string, 'UTF-8') === mb_strlen($matches[0], 'UTF-8')) {
            return $string;
        }

        return rtrim($matches[0]) . $append;
    }