/**
  * Convert URLs into links with a callback.
  *
  * @test
  * @dataProvider callbackProvider
  */
 public function makeLinkWithCallback($test, $expected)
 {
     $linkify = new Linkify(array('callback' => function ($url, $caption, $isEmail) {
         return sprintf('<callback href="%s" mail="%s">%s</callback>', $url, $isEmail, $caption);
     }));
     $this->assertEquals($expected, $linkify->process($test));
 }
 /**
  * Avoid turning non-URLs and email addresses into links.
  *
  * This makes sure that things that look like either URLs or email
  * addresses are not turned into links by Linkify::processUrls().
  *
  * @test
  * @dataProvider ignoreProvider
  */
 public function avoidNonLinks(array $data)
 {
     $linkify = new Linkify($data['options']);
     foreach ($data['tests'] as $test) {
         $this->assertEquals($test, $linkify->process($test));
     }
 }
示例#3
0
文件: Tpl.php 项目: TonyWoo/website
 public static function formatTextForDisplay($text)
 {
     $text = self::out($text);
     $linkify = new Linkify();
     $text = $linkify->process($text, array('attr' => array('target' => '_blank')));
     $text = self::emotify($text);
     return $text;
 }
 public function it_should_throw_an_exception_on_an_exception(Linkify $linkify)
 {
     $linkify->process('bar')->willThrow('Exception');
     $this->shouldThrow('TheWilkyBarKid\\TextFilter\\Exception\\TextFilterFailedException')->during('filter', array('foo'));
 }
 private function linkify($content)
 {
     $linkify = new Linkify();
     return $linkify->process($content);
 }
 protected function doFilter($text)
 {
     return $this->linkify->process($text);
 }
 /**
  * Process text.
  *
  * @param string $text    Text to process.
  * @param array  $options Options.
  *
  * @return string Processed text.
  */
 public function process($text, array $options = array())
 {
     return $this->linkify->process($text, $options);
 }
示例#8
0
 public function linkify()
 {
     $linkify = new Linkify();
     return $linkify->process($this->body);
 }