Returns a string representation of given object.

@param object $value
@param integer $level
@return string
173357
protected function printObject($value, $level = 0)
    {
        $reflector = new ReflectionClass($value);

        // Display the general information about given object.
        $result = $this->getGeneralObjectInfo($value) . PHP_EOL;

        if ( ! $this->config["object_limited_info"]) {
            // Display all parent classes.
            if (count($parents = $this->getAllParentClassNames($reflector)) > 0) {
                $result .= sprintf("Classes: %s" . PHP_EOL, implode(", ", $parents));
            }

            // Display all interfaces (interface inheritance is supported).
            if (count($interfaces = $reflector->getInterfaceNames()) > 0) {
                $result .= sprintf("Interfaces: %s" . PHP_EOL, implode(", ", $interfaces));
            }

            // Display all class traits.
            if (count($traits = $this->getAllTraitNames($reflector)) > 0) {
                $result .= sprintf("Traits: %s" . PHP_EOL, implode(", ", $traits));
            }
        }

        // Display property values.
        if ($info = $this->getPropertyValues($reflector, $value, $level + 1)) {
            $result .=
                str_repeat($this->config["array_indenting"], $level)
                . "Properties:" . PHP_EOL . $info;
        }

        return $result;
    }
420882
public static function getLevelCode(
        /*# string */ $level
    )/*# : int */ {
        if (is_string($level) &&
            isset(self::$levels[$level])) {
            return self::$levels[$level];
        }

        throw new Exception\InvalidArgumentException(
            Message::get(
                Message::INVALID_LOG_LEVEL,
                (string) $level
            ),
            Message::INVALID_LOG_LEVEL
        );
    }
827080
private function formatValue($value)
    {
        if ($value === '') {
            return '';
        }

        if ($value === null) {
            return '<comment>Null</comment>';
        }

        if (is_bool($value)) {
            return '<comment>' . ($value ? 'True' : 'False') . '</comment>';
        }

        if (empty($value)) {
            return '<comment>Empty</comment>';
        }

        if (is_array($value)) {
            return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
        }

        if (is_object($value)) {
            return sprintf('<%s>', get_class($value));
        }

        if (is_scalar($value)) {
            return $value;
        }

        throw new InvalidArgumentException(sprintf('Do not know how to format value "%s"', print_r($value, true)));
    }
1188099
public static function string($value)
    {
        if (static::stringable($value)) {
            $value = (string) $value;
        } else {
            $value = null;
        }

        return $value;
    }
103352
protected function parseAdvancedUses(string $value): MultiLevel
    {
        $level = 0;
        $uses = [''];
        $current = 0;
        $root = '';

        foreach (\str_split($value) as $char) {
            switch ($char) {
                case '{':
                    if ($level == 0) {
                        $root = $uses[0];
                        $uses[$current] = '';
                        ++$level;
                        break;
                    } else {
                        $uses[$current] .= '{';
                        ++$level;
                        break;
                    }
                    // no break
                case ',':
                    if ($level === 1) {
                        ++$current;
                        $uses[$current] = '';
                        break;
                    } else {
                        $uses[$current] .= ',';
                        break;
                    }
                    // no break
                case '}':
                    if ($level === 2) {
                        $uses[$current] .= '}';
                        --$level;
                        break;
                    } elseif ($level === 1) {
                        ++$current;
                        $uses[$current] = '';
                        --$level;
                        break;
                    }
                    // no break
                default:
                    $uses[$current] .= $char;
            }
        }

        $alias = $uses[$current] ? \str_replace('>', '', $uses[$current]) : $root;

        \array_pop($uses);

        return new MultiLevel($root, $alias, $uses);
    }
1008376
public static function toString($value): string
    {
        if ($value === null) {
            return 'NULL';
        }

        if ($value === true) {
            return 'TRUE';
        }

        if ($value === false) {
            return 'FALSE';
        }

        if (is_object($value)) {
            return static::readObject($value);
        }

        if (is_array($value)) {
            return static::readArray($value);
        }

        if (is_resource($value)) {
            return static::readResource($value);
        }

        return (string) $value;
    }
215527
private static function tostring($value) : string
    {
        if (!isset($value)) {
            return 'NULL';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }
        if (is_numeric($value)) {
            return $value;
        }
        if (is_string($value)) {
            return "'$value'";
        }
        if (is_array($value)) {
            $out = '[';
            $i = 0;
            foreach ($value as $key => $entry) {
                if ($i) {
                    $out .= ', ';
                }
                $out .= $key.' => '.self::tostring($entry);
                $i++;
            }
            $out .= ']';
            return $out;
        }
        if (is_object($value)) {
            if (method_exists($value, '__toString')) {
                return "$value";
            } else {
                return get_class($value);
            }
        }
    }
573874
public function getLevelCode($levelName)
    {
        $levelName = strtoupper($levelName);

        $levels = $this->getLevels();

        if (isset($levels[$levelName])) {
            return $levels[$levelName];
        }

        return $levels[$this->defaultLevelName];
    }
279641
public function getString($value)
    {
        $number = floatval($value);
        $number = round(($number + 0.000001) * 20) / 20;

        return sprintf('CHF %s',
            number_format($number, 2, '.', '\'')
        );
    }
323435
public function getHashKey($value) : string
    {
        if (is_string($value)) {
            return "__opulence:s:$value";
        }

        if (is_int($value)) {
            return "__opulence:i:$value";
        }

        if (is_float($value)) {
            return "__opulence:f:$value";
        }

        if (is_object($value)) {
            if (method_exists($value, '__toString')) {
                return "__opulence:so:$value";
            }

            return '__opulence:o:' . spl_object_hash($value);
        }

        if (is_array($value)) {
            return '__opulence:a:' . md5(serialize($value));
        }

        if (is_resource($value)) {
            return '__opulence:r:' . "$value";
        }

        // As a last-ditch effort, try to convert the value to a string
        try {
            return '__opulence:u' . (string)$value;
        } catch (Throwable $ex) {
            throw new RuntimeException('Value could not be converted to a key', 0, $ex);
        }
    }
702088
protected function scalarValue($value)
    {
        if (is_array($value)) {
            $data = array();
            foreach ($value as $key => $childValue) {
                $data[$key] = $this->scalarValue($childValue);
            }

            return $data;
        } else if (is_object($value)) {
            if (method_exists($value, 'toString')) {
                $value = $value->toString();
            } else if (method_exists($value, '__toString')) {
                $value = (string) $value;
            } else {
                $value = spl_object_hash($value);
            }
        }

        return html_entity_decode($value, ENT_NOQUOTES | ENT_HTML5);
    }
321976
public static function getLevelString( $level )
    {
        $name = '';

        switch ( $level )
        {
            case self::LEVEL_DEBUG:
                $name = 'DEBUG';
                break;

            case self::LEVEL_INFO:
                $name = 'INFO';
                break;

            case self::LEVEL_NOTICE:
                $name = 'NOTICE';
                break;

            case self::LEVEL_WARNING:
                $name = 'WARNING';
                break;

            case self::LEVEL_ERROR:
                $name = 'ERROR';
                break;

            case self::LEVEL_CRITICAL:
                $name = 'CRITICAL';
                break;

            case self::LEVEL_ALERT:
                $name = 'ALERT';
                break;

            case self::LEVEL_EMERGENCY:
                $name = 'EMERGENCY';
                break;

            default:
                $name = '';
                break;
        }

        return $name;
    }
742568
private function getType($value): string
    {
        if (is_array($value)) {
            if ($value !== array_values($value)) {
                return self::DATATYPE_OBJECT;
            }

            return self::DATATYPE_ARRAY;
        }

        if (is_bool($value)) {
            return self::DATATYPE_BOOLEAN;
        }

        if (is_string($value)) {
            return self::DATATYPE_STRING;
        }

        if (is_int($value) || is_float($value)) {
            return self::DATATYPE_NUMBER;
        }

        if (null === $value) {
            return self::DATATYPE_NULL;
        }

        throw new \InvalidArgumentException(
            sprintf(
                'Value needs to be of type array|bool|string|int|float|null, %s given',
                is_object($value) ? get_class($value) : gettype($value)
            )
        );
    }
1152847
public function transform($value): string
    {
        if (method_exists($value, 'toJson')) {
            return $value->toJson();
        }

        if ($value instanceof JsonSerializable || $value instanceof StdClass) {
            return json_encode($value);
        }

        if (! method_exists($value, '__toString')) {
            throw Untransformable::cannotTransformObject($value);
        }

        return "'{$value}'";
    }
1157138
public static function toString($value)
    {
        if($value == null)
        {
            return null;
        }
        $reflection = new \ReflectionClass(static::class);
        $values = $reflection->getConstants();

        //Check if input value is valid
        if(static::isValid($value, $reflection))
        {
            $constName = array_search($value, $values);
            return static::WordifyConst($constName);
        }
        else
        {
            return null;
        }
    }
668206
public function serialize($value)
    {
        $this->recursiveSetValues($value);
        $this->recursiveUnset($value, [Serializer::CLASS_IDENTIFIER_KEY]);
        $this->recursiveFlattenOneElementObjectsToScalarType($value);

        return $value;
    }
283766
private function stringifyValue($value)
    {
        switch (true) {
            case $value === null:
                $value = 'NULL';
                break;
            case ($value instanceof \DateTime):
                $value = $value->format(DATE_RFC822);
                break;
            case ($value instanceof StringableInterface):
                $value = $value->toString();
                break;
            case ($value instanceof ArrayableInterface):
                $value = sprintf('Arrayable::%s (%s)', (new \ReflectionObject($value))->getShortName(),
                    $this->stringifyValue($value->toArray()));
                break;
            case is_scalar($value):
            case method_exists($value, '__toString'):
                $value = (string) $value;
                break;
            case is_object($value):
                $value = sprintf('Object (%s)', get_class($value));
                break;
            case is_array($value):
                $value = sprintf('Array (%s)', implode(', ', array_map([$this, 'stringifyValue'], $value)));
                break;
        }
        
        return $value;
    }