aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Parameter.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/lib/Parameter.php')
-rw-r--r--vendor/sabre/vobject/lib/Parameter.php233
1 files changed, 127 insertions, 106 deletions
diff --git a/vendor/sabre/vobject/lib/Parameter.php b/vendor/sabre/vobject/lib/Parameter.php
index 2c9a8e7fd..a99a33eec 100644
--- a/vendor/sabre/vobject/lib/Parameter.php
+++ b/vendor/sabre/vobject/lib/Parameter.php
@@ -17,8 +17,8 @@ use Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Parameter extends Node
-{
+class Parameter extends Node {
+
/**
* Parameter name.
*
@@ -29,7 +29,7 @@ class Parameter extends Node
/**
* vCard 2.1 allows parameters to be encoded without a name.
*
- * We can deduce the parameter name based on its value.
+ * We can deduce the parameter name based on it's value.
*
* @var bool
*/
@@ -50,8 +50,8 @@ class Parameter extends Node
* @param string $name
* @param string $value
*/
- public function __construct(Document $root, $name, $value = null)
- {
+ function __construct(Document $root, $name, $value = null) {
+
$this->name = strtoupper($name);
$this->root = $root;
if (is_null($name)) {
@@ -62,12 +62,13 @@ class Parameter extends Node
// If guessParameterNameByValue() returns an empty string
// above, we're actually dealing with a parameter that has no value.
// In that case we have to move the value to the name.
- if ('' === $this->name) {
+ if ($this->name === '') {
$this->noName = false;
$this->name = strtoupper($value);
} else {
$this->setValue($value);
}
+
}
/**
@@ -81,85 +82,85 @@ class Parameter extends Node
*
* @return string
*/
- public static function guessParameterNameByValue($value)
- {
+ static function guessParameterNameByValue($value) {
switch (strtoupper($value)) {
+
// Encodings
- case '7-BIT':
- case 'QUOTED-PRINTABLE':
- case 'BASE64':
+ case '7-BIT' :
+ case 'QUOTED-PRINTABLE' :
+ case 'BASE64' :
$name = 'ENCODING';
break;
// Common types
- case 'WORK':
- case 'HOME':
- case 'PREF':
+ case 'WORK' :
+ case 'HOME' :
+ case 'PREF' :
// Delivery Label Type
- case 'DOM':
- case 'INTL':
- case 'POSTAL':
- case 'PARCEL':
+ case 'DOM' :
+ case 'INTL' :
+ case 'POSTAL' :
+ case 'PARCEL' :
// Telephone types
- case 'VOICE':
- case 'FAX':
- case 'MSG':
- case 'CELL':
- case 'PAGER':
- case 'BBS':
- case 'MODEM':
- case 'CAR':
- case 'ISDN':
- case 'VIDEO':
+ case 'VOICE' :
+ case 'FAX' :
+ case 'MSG' :
+ case 'CELL' :
+ case 'PAGER' :
+ case 'BBS' :
+ case 'MODEM' :
+ case 'CAR' :
+ case 'ISDN' :
+ case 'VIDEO' :
// EMAIL types (lol)
- case 'AOL':
- case 'APPLELINK':
- case 'ATTMAIL':
- case 'CIS':
- case 'EWORLD':
- case 'INTERNET':
- case 'IBMMAIL':
- case 'MCIMAIL':
- case 'POWERSHARE':
- case 'PRODIGY':
- case 'TLX':
- case 'X400':
+ case 'AOL' :
+ case 'APPLELINK' :
+ case 'ATTMAIL' :
+ case 'CIS' :
+ case 'EWORLD' :
+ case 'INTERNET' :
+ case 'IBMMAIL' :
+ case 'MCIMAIL' :
+ case 'POWERSHARE' :
+ case 'PRODIGY' :
+ case 'TLX' :
+ case 'X400' :
// Photo / Logo format types
- case 'GIF':
- case 'CGM':
- case 'WMF':
- case 'BMP':
- case 'DIB':
- case 'PICT':
- case 'TIFF':
- case 'PDF':
- case 'PS':
- case 'JPEG':
- case 'MPEG':
- case 'MPEG2':
- case 'AVI':
- case 'QTIME':
+ case 'GIF' :
+ case 'CGM' :
+ case 'WMF' :
+ case 'BMP' :
+ case 'DIB' :
+ case 'PICT' :
+ case 'TIFF' :
+ case 'PDF' :
+ case 'PS' :
+ case 'JPEG' :
+ case 'MPEG' :
+ case 'MPEG2' :
+ case 'AVI' :
+ case 'QTIME' :
// Sound Digital Audio Type
- case 'WAVE':
- case 'PCM':
- case 'AIFF':
+ case 'WAVE' :
+ case 'PCM' :
+ case 'AIFF' :
// Key types
- case 'X509':
- case 'PGP':
+ case 'X509' :
+ case 'PGP' :
$name = 'TYPE';
break;
// Value types
- case 'INLINE':
- case 'URL':
- case 'CONTENT-ID':
- case 'CID':
+ case 'INLINE' :
+ case 'URL' :
+ case 'CONTENT-ID' :
+ case 'CID' :
$name = 'VALUE';
break;
@@ -176,10 +177,13 @@ class Parameter extends Node
* This may be either a single, or multiple strings in an array.
*
* @param string|array $value
+ *
+ * @return void
*/
- public function setValue($value)
- {
+ function setValue($value) {
+
$this->value = $value;
+
}
/**
@@ -190,23 +194,27 @@ class Parameter extends Node
*
* @return string|null
*/
- public function getValue()
- {
+ function getValue() {
+
if (is_array($this->value)) {
return implode(',', $this->value);
} else {
return $this->value;
}
+
}
/**
* Sets multiple values for this parameter.
*
* @param array $value
+ *
+ * @return void
*/
- public function setParts(array $value)
- {
+ function setParts(array $value) {
+
$this->value = $value;
+
}
/**
@@ -216,8 +224,8 @@ class Parameter extends Node
*
* @return array
*/
- public function getParts()
- {
+ function getParts() {
+
if (is_array($this->value)) {
return $this->value;
} elseif (is_null($this->value)) {
@@ -225,6 +233,7 @@ class Parameter extends Node
} else {
return [$this->value];
}
+
}
/**
@@ -234,14 +243,17 @@ class Parameter extends Node
* parameter value list.
*
* @param string|array $part
+ *
+ * @return void
*/
- public function addValue($part)
- {
+ function addValue($part) {
+
if (is_null($this->value)) {
$this->value = $part;
} else {
- $this->value = array_merge((array) $this->value, (array) $part);
+ $this->value = array_merge((array)$this->value, (array)$part);
}
+
}
/**
@@ -255,12 +267,13 @@ class Parameter extends Node
*
* @return bool
*/
- public function has($value)
- {
+ function has($value) {
+
return in_array(
strtolower($value),
- array_map('strtolower', (array) $this->value)
+ array_map('strtolower', (array)$this->value)
);
+
}
/**
@@ -268,24 +281,25 @@ class Parameter extends Node
*
* @return string
*/
- public function serialize()
- {
+ function serialize() {
+
$value = $this->getParts();
- if (0 === count($value)) {
- return $this->name.'=';
+ if (count($value) === 0) {
+ return $this->name . '=';
}
- if (Document::VCARD21 === $this->root->getDocumentType() && $this->noName) {
+ if ($this->root->getDocumentType() === Document::VCARD21 && $this->noName) {
+
return implode(';', $value);
+
}
- return $this->name.'='.array_reduce(
+ return $this->name . '=' . array_reduce(
$value,
- function ($out, $item) {
- if (!is_null($out)) {
- $out .= ',';
- }
+ function($out, $item) {
+
+ if (!is_null($out)) $out .= ',';
// If there's no special characters in the string, we'll use the simple
// format.
@@ -304,23 +318,24 @@ class Parameter extends Node
// severaly trips on + characters not being quoted, so we
// added + as well.
if (!preg_match('#(?: [\n":;\^,\+] )#x', $item)) {
- return $out.$item;
+ return $out . $item;
} else {
// Enclosing in double-quotes, and using RFC6868 for encoding any
// special characters
- $out .= '"'.strtr(
+ $out .= '"' . strtr(
$item,
[
- '^' => '^^',
+ '^' => '^^',
"\n" => '^n',
- '"' => '^\'',
+ '"' => '^\'',
]
- ).'"';
-
+ ) . '"';
return $out;
}
+
}
);
+
}
/**
@@ -329,22 +344,26 @@ class Parameter extends Node
*
* @return array
*/
- public function jsonSerialize()
- {
+ function jsonSerialize() {
+
return $this->value;
+
}
/**
* This method serializes the data into XML. This is used to create xCard or
* xCal documents.
*
- * @param Xml\Writer $writer XML writer
+ * @param Xml\Writer $writer XML writer.
+ *
+ * @return void
*/
- public function xmlSerialize(Xml\Writer $writer)
- {
+ function xmlSerialize(Xml\Writer $writer) {
+
foreach (explode(',', $this->value) as $value) {
$writer->writeElement('text', $value);
}
+
}
/**
@@ -352,9 +371,10 @@ class Parameter extends Node
*
* @return string
*/
- public function __toString()
- {
- return (string) $this->getValue();
+ function __toString() {
+
+ return (string)$this->getValue();
+
}
/**
@@ -362,12 +382,13 @@ class Parameter extends Node
*
* @return ElementList
*/
- public function getIterator()
- {
- if (!is_null($this->iterator)) {
+ function getIterator() {
+
+ if (!is_null($this->iterator))
return $this->iterator;
- }
- return $this->iterator = new ArrayIterator((array) $this->value);
+ return $this->iterator = new ArrayIterator((array)$this->value);
+
}
+
}