117 if (is_array($this->value)) {
118 if (
count($this->value) == 0) {
120 } elseif (
count($this->value) === 1) {
121 return $this->value[0];
140 $this->value = $parts;
154 if (is_null($this->value)) {
156 } elseif (is_array($this->value)) {
176 if (
$name ===
null) {
186 $param->noName = $noName;
239 if ($this->group) $str = $this->group .
'.' .
$this->name;
243 $str .=
';' . $param->serialize();
249 $str = \preg_replace(
251 (?:^.)? # 1 additional byte in first line because of missing single space (see next line)
252 .{1,74} # max 75 bytes per line (1 byte is used for a single space added after every CRLF)
253 (?![\x80-\xbf]) # prevent splitting multibyte characters
260 return \substr($str, 0, -1);
307 if ($parameter->name ===
'VALUE') {
310 $parameters[strtolower($parameter->name)] = $parameter->jsonSerialize();
320 strtolower($this->name),
356 if ($parameter->name ===
'VALUE') {
364 $writer->startElement(strtolower($this->name));
368 $writer->startElement(
'parameters');
372 $writer->startElement(strtolower($parameter->name));
373 $writer->write($parameter);
374 $writer->endElement();
378 $writer->endElement();
383 $writer->endElement();
401 $writer->writeElement($valueType,
$value);
433 if (is_int(
$name))
return parent::offsetExists(
$name);
438 if ($parameter->name ==
$name)
return true;
455 if (is_int(
$name))
return parent::offsetGet(
$name);
500 parent::offsetUnset(
$name);
565 if (preg_match(
'%([\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', $oldValue, $matches)) {
566 $message =
'Property contained a control character (0x' . bin2hex($matches[1]) .
')';
568 $message =
'Property is not valid UTF-8! ' . $oldValue;
579 if (!preg_match(
'/^([A-Z0-9-]+)$/', $this->name)) {
581 'level' =>
$options & self::REPAIR ? 1 : 3,
582 'message' =>
'The propertyname: ' . $this->name .
' contains invalid characters. Only A-Z, 0-9 and - are allowed',
587 $this->name = strtoupper(
588 str_replace(
'_',
'-', $this->name)
591 $this->name = preg_replace(
'/([^A-Z0-9-])/u',
'', $this->name);
597 if ($encoding = $this->
offsetGet(
'ENCODING')) {
602 'message' =>
'ENCODING parameter is not valid in vCard 4.',
607 $encoding = (string)$encoding;
609 $allowedEncoding = [];
611 switch ($this->root->getDocumentType()) {
613 $allowedEncoding = [
'8BIT',
'BASE64'];
616 $allowedEncoding = [
'QUOTED-PRINTABLE',
'BASE64',
'8BIT'];
619 $allowedEncoding = [
'B'];
623 if ($allowedEncoding && !in_array(strtoupper($encoding), $allowedEncoding)) {
626 'message' =>
'ENCODING=' . strtoupper($encoding) .
' is not valid for this document type.',
An exception for terminatinating execution or to throw for unit testing.
const ICALENDAR20
iCalendar 2.0.
A node is the root class for every element in an iCalendar of vCard object.
count()
Returns the number of elements.
static guessParameterNameByValue($value)
Try to guess property name by value, can be used for vCard 2.1 nameless parameters.
parameters()
Returns an iterable list of children.
serialize()
Turns the object back into a serialized blob.
getValueType()
Returns the type of value.
offsetUnset($name)
Removes one or more parameters with the specified name.
getParts()
Returns a multi-valued property.
xmlSerializeValue(Xml\Writer $writer)
This method serializes only the value of a property.
setJsonValue(array $value)
Sets the JSON value, as it would appear in a jCard or jCal object.
__toString()
Called when this object is being cast to a string.
__construct(Component $root, $name, $value=null, array $parameters=[], $group=null)
Creates the generic property.
__clone()
This method is automatically called when the object is cloned.
add($name, $value=null)
Adds a new parameter.
offsetExists($name)
Checks if an array element exists.
xmlSerialize(Xml\Writer $writer)
This method serializes the data into XML.
validate($options=0)
Validates the node for correctness.
getValue()
Returns the current value.
jsonSerialize()
This method returns an array, with the representation as it should be encoded in JSON.
getJsonValue()
Returns the value, in the format it should be encoded for JSON.
offsetGet($name)
Returns a parameter.
destroy()
Call this method on a document if you're done using it.
offsetSet($name, $value)
Creates a new parameter.
setRawMimeDirValue($val)
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
getRawMimeDirValue()
Returns a raw mime-dir representation of the value.
setParts(array $parts)
Sets a multi-valued property.
setXmlValue(array $value)
Hydrate data from a XML subtree, as it would appear in a xCard or xCal object.
setValue($value)
Updates the current value.
static convertToUTF8($str)
This method tries its best to convert the input string to UTF-8.
static isUTF8($str)
Returns true or false depending on if a string is valid UTF-8.
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
catch(Exception $e) $message