Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-01-08 01:32:02 +0300
committerOlivier Paroz <github@oparoz.com>2015-01-08 01:32:02 +0300
commitc375c225522f66bfca719508bcd780cbd1596786 (patch)
tree93ff7f792cea85348878f351c3baa9a8535ae499 /utility
parentc258fd747c404742862f1ffe6810260a8b057c1a (diff)
Trying to reduce the complexity of normalize again...
Diffstat (limited to 'utility')
-rw-r--r--utility/smarterlogger.php52
1 files changed, 30 insertions, 22 deletions
diff --git a/utility/smarterlogger.php b/utility/smarterlogger.php
index 261793ac..4cc2e11c 100644
--- a/utility/smarterlogger.php
+++ b/utility/smarterlogger.php
@@ -184,15 +184,11 @@ class SmarterLogger implements ILogger {
return $data;
}
- if (is_array($data) || $data instanceof \Traversable) {
+ if ($this->normalizeTraversable($data)) {
return $this->normalizeTraversable($data);
}
- if (is_object($data)) {
- if ($data instanceof \Exception) {
- return $this->normalizeException($data);
- }
-
+ if ($this->normalizeObject($data)) {
return $this->normalizeObject($data);
}
@@ -211,19 +207,23 @@ class SmarterLogger implements ILogger {
* @return string
*/
private function normalizeTraversable($data) {
- $normalized = array();
- $count = 1;
- foreach ($data as $key => $value) {
- if ($count >= 1000) {
- $normalized['...'] =
- 'Over 1000 items, aborting normalization';
- break;
+ if (is_array($data) || $data instanceof \Traversable) {
+ $normalized = array();
+ $count = 1;
+ foreach ($data as $key => $value) {
+ if ($count >= 1000) {
+ $normalized['...'] =
+ 'Over 1000 items, aborting normalization';
+ break;
+ }
+ $normalized[$key] = $this->normalize($value);
}
- $normalized[$key] = $this->normalize($value);
+
+ //return $normalized;
+ return $this->toJson($normalized);
}
- //return $normalized;
- return $this->toJson($normalized);
+ return null;
}
/**
@@ -234,13 +234,21 @@ class SmarterLogger implements ILogger {
* @return string
*/
private function normalizeObject($data) {
- $arrayObject = new \ArrayObject($data);
- $serializedObject = $arrayObject->getArrayCopy();
+ if (is_object($data)) {
+ if ($data instanceof \Exception) {
+ return $this->normalizeException($data);
+ }
- return sprintf(
- "[object] (%s: %s)", get_class($data),
- $this->toJson($serializedObject)
- );
+ $arrayObject = new \ArrayObject($data);
+ $serializedObject = $arrayObject->getArrayCopy();
+
+ return sprintf(
+ "[object] (%s: %s)", get_class($data),
+ $this->toJson($serializedObject)
+ );
+ }
+
+ return null;
}
/**