aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Parser/Json.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-04-25 11:47:18 +0200
committerMario Vavti <mario@mariovavti.com>2019-04-25 11:47:18 +0200
commita60c2f38c689f254bd8bb8e7ea9af78bf21c1f84 (patch)
tree65d1d73918ccb1d4ccc36184d70af2e8dd91f28e /vendor/sabre/vobject/lib/Parser/Json.php
parentf1c07977809ce3221286d53e99f0d91145b1166f (diff)
downloadvolse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.gz
volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.bz2
volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.zip
update sabre/vobject
Diffstat (limited to 'vendor/sabre/vobject/lib/Parser/Json.php')
-rw-r--r--vendor/sabre/vobject/lib/Parser/Json.php63
1 files changed, 29 insertions, 34 deletions
diff --git a/vendor/sabre/vobject/lib/Parser/Json.php b/vendor/sabre/vobject/lib/Parser/Json.php
index a77258a2e..3fd307e97 100644
--- a/vendor/sabre/vobject/lib/Parser/Json.php
+++ b/vendor/sabre/vobject/lib/Parser/Json.php
@@ -4,6 +4,7 @@ namespace Sabre\VObject\Parser;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VCard;
+use Sabre\VObject\Document;
use Sabre\VObject\EofException;
use Sabre\VObject\ParseException;
@@ -16,8 +17,8 @@ use Sabre\VObject\ParseException;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Json extends Parser {
-
+class Json extends Parser
+{
/**
* The input data.
*
@@ -41,12 +42,12 @@ class Json extends Parser {
* If either input or options are not supplied, the defaults will be used.
*
* @param resource|string|array|null $input
- * @param int $options
+ * @param int $options
*
- * @return Sabre\VObject\Document
+ * @return \Sabre\VObject\Document
*/
- function parse($input = null, $options = 0) {
-
+ public function parse($input = null, $options = 0)
+ {
if (!is_null($input)) {
$this->setInput($input);
}
@@ -59,28 +60,28 @@ class Json extends Parser {
}
switch ($this->input[0]) {
- case 'vcalendar' :
+ case 'vcalendar':
$this->root = new VCalendar([], false);
break;
- case 'vcard' :
+ case 'vcard':
$this->root = new VCard([], false);
break;
- default :
+ default:
throw new ParseException('The root component must either be a vcalendar, or a vcard');
-
}
foreach ($this->input[1] as $prop) {
$this->root->add($this->parseProperty($prop));
}
- if (isset($this->input[2])) foreach ($this->input[2] as $comp) {
- $this->root->add($this->parseComponent($comp));
+ if (isset($this->input[2])) {
+ foreach ($this->input[2] as $comp) {
+ $this->root->add($this->parseComponent($comp));
+ }
}
// Resetting the input so we can throw an feof exception the next time.
$this->input = null;
return $this->root;
-
}
/**
@@ -90,35 +91,34 @@ class Json extends Parser {
*
* @return \Sabre\VObject\Component
*/
- function parseComponent(array $jComp) {
-
+ public function parseComponent(array $jComp)
+ {
// We can remove $self from PHP 5.4 onward.
$self = $this;
$properties = array_map(
- function($jProp) use ($self) {
+ function ($jProp) use ($self) {
return $self->parseProperty($jProp);
},
$jComp[1]
);
if (isset($jComp[2])) {
-
$components = array_map(
- function($jComp) use ($self) {
+ function ($jComp) use ($self) {
return $self->parseComponent($jComp);
},
$jComp[2]
);
-
- } else $components = [];
+ } else {
+ $components = [];
+ }
return $this->root->createComponent(
$jComp[0],
array_merge($properties, $components),
$defaults = false
);
-
}
/**
@@ -128,8 +128,8 @@ class Json extends Parser {
*
* @return \Sabre\VObject\Property
*/
- function parseProperty(array $jProp) {
-
+ public function parseProperty(array $jProp)
+ {
list(
$propertyName,
$parameters,
@@ -142,14 +142,14 @@ class Json extends Parser {
// value type. We're using this value later in this function.
$defaultPropertyClass = $this->root->getClassNameForPropertyName($propertyName);
- $parameters = (array)$parameters;
+ $parameters = (array) $parameters;
$value = array_slice($jProp, 3);
$valueType = strtoupper($valueType);
if (isset($parameters['group'])) {
- $propertyName = $parameters['group'] . '.' . $propertyName;
+ $propertyName = $parameters['group'].'.'.$propertyName;
unset($parameters['group']);
}
@@ -160,7 +160,7 @@ class Json extends Parser {
// represents TEXT values. We have to normalize these here. In the
// future we can get rid of FlatText once we're allowed to break BC
// again.
- if ($defaultPropertyClass === 'Sabre\VObject\Property\FlatText') {
+ if ('Sabre\VObject\Property\FlatText' === $defaultPropertyClass) {
$defaultPropertyClass = 'Sabre\VObject\Property\Text';
}
@@ -168,22 +168,19 @@ class Json extends Parser {
// type for the given property (e.g.: BDAY), we need to add a VALUE=
// parameter.
if ($defaultPropertyClass !== get_class($prop)) {
- $prop["VALUE"] = $valueType;
+ $prop['VALUE'] = $valueType;
}
return $prop;
-
}
/**
* Sets the input data.
*
* @param resource|string|array $input
- *
- * @return void
*/
- function setInput($input) {
-
+ public function setInput($input)
+ {
if (is_resource($input)) {
$input = stream_get_contents($input);
}
@@ -191,7 +188,5 @@ class Json extends Parser {
$input = json_decode($input);
}
$this->input = $input;
-
}
-
}