| <?php |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| namespace Eluceo\iCal; |
|
|
| use Eluceo\iCal\Property\ArrayValue; |
| use Eluceo\iCal\Property\StringValue; |
| use Eluceo\iCal\Property\ValueInterface; |
|
|
| |
| |
| |
| |
| |
| |
| |
| class Property |
| { |
| |
| |
| |
| |
| |
| protected $value; |
|
|
| |
| |
| |
| |
| |
| protected $parameterBag; |
|
|
| |
| |
| |
| protected $name; |
|
|
| |
| |
| |
| |
| |
| public function __construct($name, $value, $params = []) |
| { |
| $this->name = $name; |
| $this->setValue($value); |
| $this->parameterBag = new ParameterBag($params); |
| } |
|
|
| |
| |
| |
| |
| |
| public function toLine() |
| { |
| |
| $line = $this->getName(); |
|
|
| |
| |
| if ($this->parameterBag && $this->parameterBag->hasParams()) { |
| $line .= ';' . $this->parameterBag->toString(); |
| } |
|
|
| |
| $line .= ':' . $this->value->getEscapedValue(); |
|
|
| return $line; |
| } |
|
|
| |
| |
| |
| |
| |
| public function toLines() |
| { |
| return [$this->toLine()]; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function setParam($name, $value) |
| { |
| $this->parameterBag->setParam($name, $value); |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| public function getParam($name) |
| { |
| return $this->parameterBag->getParam($name); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function setValue($value) |
| { |
| if (is_scalar($value)) { |
| $this->value = new StringValue($value); |
| } elseif (is_array($value)) { |
| $this->value = new ArrayValue($value); |
| } else { |
| if (!$value instanceof ValueInterface) { |
| throw new \Exception('The value must implement the ValueInterface.'); |
| } else { |
| $this->value = $value; |
| } |
| } |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| public function getValue() |
| { |
| return $this->value; |
| } |
|
|
| public function getName(): string |
| { |
| return $this->name; |
| } |
| } |
|
|