[Pkg-owncloud-commits] [php-sabre-vobject] 174/341: Simplify the code by using `Xml::writeElement`…

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:35:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 6b6361088384b79b42fef16306e14abd2b4fb70f
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date:   Thu Jan 22 08:50:45 2015 +0100

    Simplify the code by using `Xml::writeElement`…
    
    … instead of `Xml::startElement`, `Xml::write` and `Xml::endElement`.
---
 lib/Property.php                  | 10 ++--------
 lib/Property/Float.php            |  9 ++-------
 lib/Property/ICalendar/Period.php | 13 +++----------
 lib/Property/Text.php             | 15 +++------------
 4 files changed, 10 insertions(+), 37 deletions(-)

diff --git a/lib/Property.php b/lib/Property.php
index 4bfe1b7..a42bd4e 100644
--- a/lib/Property.php
+++ b/lib/Property.php
@@ -364,9 +364,7 @@ abstract class Property extends Node {
             foreach ($parameters as $parameter) {
 
                 $writer->startElement(strtolower($parameter->name));
-                    $writer->startElement('text');
-                        $parameter->xmlSerialize($writer);
-                    $writer->endElement();
+                $writer->writeElement('text', $parameter);
                 $writer->endElement();
 
             }
@@ -390,11 +388,7 @@ abstract class Property extends Node {
     protected function xmlSerializeValue(Xml\Writer $writer) {
 
         foreach ($this->getJsonValue() as $value) {
-
-            $writer->startElement(strtolower($this->getValueType()));
-                $writer->write($value);
-            $writer->endElement();
-
+            $writer->writeElement(strtolower($this->getValueType()), $value);
         }
 
     }
diff --git a/lib/Property/Float.php b/lib/Property/Float.php
index 6034d6c..de795f0 100644
--- a/lib/Property/Float.php
+++ b/lib/Property/Float.php
@@ -127,13 +127,8 @@ class Float extends Property {
 
             $value = array_map('floatval', $this->getParts());
 
-            $writer->startElement('latitude');
-                $writer->write($value[0]);
-            $writer->endElement();
-
-            $writer->startElement('longitude');
-                $writer->write($value[1]);
-            $writer->endElement();
+            $writer->writeElement('latitude', $value[0]);
+            $writer->writeElement('longitude', $value[1]);
 
         }
         else {
diff --git a/lib/Property/ICalendar/Period.php b/lib/Property/ICalendar/Period.php
index d36a2e3..98ba313 100644
--- a/lib/Property/ICalendar/Period.php
+++ b/lib/Property/ICalendar/Period.php
@@ -136,23 +136,16 @@ class Period extends Property {
     protected function xmlSerializeValue(Xml\Writer $writer) {
 
         $writer->startElement(strtolower($this->getValueType()));
-
         $value = $this->getJsonValue();
-
-        $writer->startElement('start');
-            $writer->write($value[0][0]);
-        $writer->endElement();
+        $writer->writeElement('start', $value[0][0]);
 
         if ($value[0][1][0] === 'P') {
-            $writer->startElement('duration');
+            $writer->writeElement('duration', $value[0][1]);
         }
         else {
-            $writer->startElement('end');
+            $writer->writeElement('end', $value[0][1]);
         }
 
-        $writer->write($value[0][1]);
-        $writer->endElement();
-
         $writer->endElement();
 
     }
diff --git a/lib/Property/Text.php b/lib/Property/Text.php
index 1832d60..0249743 100644
--- a/lib/Property/Text.php
+++ b/lib/Property/Text.php
@@ -304,20 +304,11 @@ class Text extends Property {
 
             $value = $this->getJsonValue();
 
-            $writer->startElement('code');
-                $writer->write($value[0][0]);
-            $writer->endElement();
-
-            $writer->startElement('description');
-                $writer->write($value[0][1]);
-            $writer->endElement();
+            $writer->writeElement('code', $value[0][0]);
+            $writer->writeElement('description', $value[0][1]);
 
             if (isset($value[0][2])) {
-
-                $writer->startElement('data');
-                    $writer->write($value[0][2]);
-                $writer->endElement();
-
+                $writer->writeElement('data', $value[0][2]);
             }
 
         }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list