132 lines
2.4 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* PHPWord
2012-05-06 18:25:40 +02:00
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
2014-05-04 21:03:28 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Link element
*/
class Link extends AbstractElement
{
/**
2014-04-26 16:05:29 +07:00
* Link target
*
* @var string
*/
2014-04-26 16:05:29 +07:00
private $target;
/**
2014-04-26 16:05:29 +07:00
* Link text
*
* @var string
*/
2014-04-26 16:05:29 +07:00
private $text;
/**
2014-04-03 08:44:41 +07:00
* Font style
*
* @var string|\PhpOffice\PhpWord\Style\Font
*/
2014-04-03 08:44:41 +07:00
private $fontStyle;
/**
* Paragraph style
*
* @var string|\PhpOffice\PhpWord\Style\Paragraph
*/
2014-04-03 08:44:41 +07:00
private $paragraphStyle;
/**
* Create a new Link Element
*
* @param string $target
* @param string $text
2014-04-03 08:44:41 +07:00
* @param mixed $fontStyle
* @param mixed $paragraphStyle
*/
2014-04-26 16:05:29 +07:00
public function __construct($target, $text = null, $fontStyle = null, $paragraphStyle = null)
{
$this->target = String::toUTF8($target);
$this->text = is_null($text) ? $this->target : String::toUTF8($text);
2014-04-03 08:44:41 +07:00
$this->fontStyle = $this->setStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
return $this;
}
/**
2014-04-26 16:05:29 +07:00
* Get link target
*
* @return string
*/
2014-04-26 16:05:29 +07:00
public function getTarget()
{
2014-04-26 16:05:29 +07:00
return $this->target;
}
/**
2014-04-26 16:05:29 +07:00
* Get link text
*
* @return string
*/
2014-04-26 16:05:29 +07:00
public function getText()
{
2014-04-26 16:05:29 +07:00
return $this->text;
}
/**
* Get Text style
*
* @return string|\PhpOffice\PhpWord\Style\Font
*/
public function getFontStyle()
{
2014-04-03 08:44:41 +07:00
return $this->fontStyle;
}
/**
* Get Paragraph style
*
* @return string|\PhpOffice\PhpWord\Style\Paragraph
*/
public function getParagraphStyle()
{
2014-04-03 08:44:41 +07:00
return $this->paragraphStyle;
}
2014-04-26 16:05:29 +07:00
/**
* Get Link source
*
* @return string
* @deprecated 0.10.0
* @codeCoverageIgnore
2014-04-26 16:05:29 +07:00
*/
public function getLinkSrc()
{
return $this->getTarget();
}
/**
* Get Link name
*
* @return string
* @deprecated 0.10.0
* @codeCoverageIgnore
2014-04-26 16:05:29 +07:00
*/
public function getLinkName()
{
return $this->getText();
}
2012-05-06 18:25:40 +02:00
}