TbHtml::quote PHP Method

quote() public static method

Generates a quote.
public static quote ( string $text, array $htmlOptions = [] ) : string
$text string the quoted text.
$htmlOptions array additional HTML attributes.
return string the generated quote.
    public static function quote($text, $htmlOptions = array())
    {
        $paragraphOptions = TbArray::popValue('paragraphOptions', $htmlOptions, array());
        $source = TbArray::popValue('source', $htmlOptions);
        $sourceOptions = TbArray::popValue('sourceOptions', $htmlOptions, array());
        $cite = TbArray::popValue('cite', $htmlOptions);
        $citeOptions = TbArray::popValue('citeOptions', $htmlOptions, array());
        $cite = isset($cite) ? ' ' . self::tag('cite', $citeOptions, $cite) : '';
        $source = isset($source) ? self::tag('small', $sourceOptions, $source . $cite) : '';
        $text = self::tag('p', $paragraphOptions, $text) . $source;
        return self::tag('blockquote', $htmlOptions, $text);
    }

Usage Example

Example #1
0
 public function testQuote()
 {
     $I = $this->codeGuy;
     $html = TbHtml::quote('Quote text', array('paragraphOptions' => array('class' => 'paragraph'), 'source' => 'Source text', 'sourceOptions' => array('class' => 'source'), 'cite' => 'Cited text', 'citeOptions' => array('class' => 'cite')));
     $blockquote = $I->createNode($html, 'blockquote');
     $I->seeNodeChildren($blockquote, array('p', 'small'));
     $p = $blockquote->filter('p');
     $I->seeNodeCssClass($p, 'paragraph');
     $I->seeNodeText($p, 'Quote text');
     $small = $blockquote->filter('blockquote > small');
     $I->seeNodeCssClass($small, 'source');
     $I->seeNodeText($small, 'Source text');
     $cite = $small->filter('small > cite');
     $I->seeNodeCssClass($cite, 'cite');
     $I->seeNodeText($cite, 'Cited text');
     // todo: consider writing a test including the pull-right quote as well.
 }
All Usage Examples Of TbHtml::quote
TbHtml