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);
288 if (
count($value) === 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();
400 foreach ((array)$values as
$value) {
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.',
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
setXmlValue(array $value)
Hydrate data from a XML subtree, as it would appear in a xCard or xCal object.
setRawMimeDirValue($val)
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
jsonSerialize()
This method returns an array, with the representation as it should be encoded in JSON.
setValue($value)
Updates the current value.
offsetExists($name)
Checks if an array element exists.
static isUTF8($str)
Returns true or false depending on if a string is valid UTF-8.
offsetGet($name)
Returns a parameter.
destroy()
Call this method on a document if you're done using it.
static convertToUTF8($str)
This method tries its best to convert the input string to UTF-8.
getValueType()
Returns the type of value.
xmlSerializeValue(Xml\Writer $writer)
This method serializes only the value of a property.
getJsonValue()
Returns the value, in the format it should be encoded for JSON.
xmlSerialize(Xml\Writer $writer)
This method serializes the data into XML.
getParts()
Returns a multi-valued property.
catch(Exception $e) $message
__construct(Component $root, $name, $value=null, array $parameters=[], $group=null)
Creates the generic property.
add($name, $value=null)
Adds a new parameter.
A node is the root class for every element in an iCalendar of vCard object.
setParts(array $parts)
Sets a multi-valued property.
validate($options=0)
Validates the node for correctness.
const ICALENDAR20
iCalendar 2.0.
parameters()
Returns an iterable list of children.
offsetUnset($name)
Removes one or more parameters with the specified name.
count()
Returns the number of elements.
getRawMimeDirValue()
Returns a raw mime-dir representation of the value.
getValue()
Returns the current value.
offsetSet($name, $value)
Creates a new parameter.
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.
static guessParameterNameByValue($value)
Try to guess property name by value, can be used for vCard 2.1 nameless parameters.
__clone()
This method is automatically called when the object is cloned.
serialize()
Turns the object back into a serialized blob.