PHP Class Bolt\Helpers\Excerpt

显示文件 Open project: bolt/bolt Class Usage Examples

Protected Properties

Property Type Description
$body Bolt\Legacy\Content | array | string
$title string

Public Methods

Method Description
__construct ( Content | array | string $body, string | null $title = null ) Constructor.
getExcerpt ( integer $length = 200, boolean $includeTitle = false, array | string | null $focus = null ) : string | null Get the excerpt of a given piece of text.

Private Methods

Method Description
determineSnipLocation ( array $locations, integer $prevCount ) : integer Work out which is the most relevant portion to display This is done by looping over each match and finding the smallest distance between two found strings. The idea being that the closer the terms are the better match the snippet would be.
extractLocations ( array $words, string $fulltext ) : array Find the locations of each of the words.
extractRelevant ( string | array $words, string $fulltext, integer $relLength = 300 ) : mixed | string Center on, and highlight search terms in excerpts.

Method Details

__construct() public method

Constructor.
public __construct ( Content | array | string $body, string | null $title = null )
$body Bolt\Legacy\Content | array | string
$title string | null

getExcerpt() public method

Get the excerpt of a given piece of text.
public getExcerpt ( integer $length = 200, boolean $includeTitle = false, array | string | null $focus = null ) : string | null
$length integer
$includeTitle boolean
$focus array | string | null
return string | null

Property Details

$body protected_oe property

protected Content,Bolt\Legacy|array|string $body
return Bolt\Legacy\Content | array | string

$title protected_oe property

protected string $title
return string