Bolt\Twig\Handler\RecordHandler::excerpt PHP Method

excerpt() public method

Create an excerpt for the given content.
public excerpt ( Content | array | string $content, integer $length = 200, array | string | null $focus = null ) : string
$content Bolt\Legacy\Content | array | string
$length integer Defaults to 200 characters
$focus array | string | null
return string Resulting excerpt
    public function excerpt($content, $length = 200, $focus = null)
    {
        $excerpter = new Excerpt($content);
        $excerpt = $excerpter->getExcerpt($length, false, $focus);
        return $excerpt;
    }

Usage Example

Example #1
0
 public function testExcerptNull()
 {
     $app = $this->getApp();
     $handler = new RecordHandler($app);
     $result = $handler->excerpt(null);
     $this->assertSame('', $result);
 }