diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-04-25 08:52:50 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2019-04-25 08:52:50 +0200 |
commit | e779335d060b3a51d6a144d23af4097ae6801473 (patch) | |
tree | 2427765313f715a0e5b48228abe5200cb82b787f /vendor/sabre/vobject/lib/Parser/Json.php | |
parent | e937e8fff96a935b14a479c062f6b0d00b90b99d (diff) | |
download | volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.gz volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.bz2 volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.zip |
update composer libs
Diffstat (limited to 'vendor/sabre/vobject/lib/Parser/Json.php')
-rw-r--r-- | vendor/sabre/vobject/lib/Parser/Json.php | 63 |
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; - } - } |