1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /*
- * This file is part of Raven.
- *
- * (c) Sentry Team
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * Serializes a value into a representation that should reasonably suggest
- * both the type and value, and be serializable into JSON.
- * @package raven
- */
- class Raven_ReprSerializer extends Raven_Serializer
- {
- protected function serializeValue($value)
- {
- if ($value === null) {
- return 'null';
- } elseif ($value === false) {
- return 'false';
- } elseif ($value === true) {
- return 'true';
- } elseif (is_float($value) && (int) $value == $value) {
- return $value.'.0';
- } elseif (is_integer($value) || is_float($value)) {
- return (string) $value;
- } elseif (is_object($value) || gettype($value) == 'object') {
- return 'Object '.get_class($value);
- } elseif (is_resource($value)) {
- return 'Resource '.get_resource_type($value);
- } elseif (is_array($value)) {
- return 'Array of length ' . count($value);
- } else {
- return $this->serializeString($value);
- }
- }
- }
|