@param mixed  $data
@param string $root
@param int    $level
@param bool   $format

@return string
485377
public static function arrayToXml($data, $root = null, $level = 1, $format = true)
    {
        if (empty($root)) {
            $root = config('df.xml_root', 'dfapi');
        }

        return '<?xml version="1.0" ?>' . static::arrayToXmlInternal($data, $root, $level, $format);
    }
917440
public function toString($format = Format::JSON, $options = [])
    {
        return StructureHelper::toString($this->data, $format, $options);
    }
414946
public static function build(
        $data,
        $root = 'xml',
        $item = 'item',
        $attr = '',
        $id = 'id'
    ) {
        if (is_array($attr)) {
            $_attr = array();

            foreach ($attr as $key => $value) {
                $_attr[] = "{$key}=\"{$value}\"";
            }

            $attr = implode(' ', $_attr);
        }

        $attr = trim($attr);
        $attr = empty($attr) ? '' : " {$attr}";
        $xml = "<{$root}{$attr}>";
        $xml  .= self::data2Xml($data, $item, $id);
        $xml  .= "</{$root}>";

        return $xml;
    }
452268
private function generateResult($format, $data, $trigger = true) {
        $etime = time();
        if ($trigger) {
            if (isset($data['error'])) {
                if ($this->api) {
                    fire('restful\errApi', $this->api, $etime, $data);
                }
                fire('restful\callError', $etime, $data);
            }
            fire('restful\endCall', $etime, $data);
        }
        if ($format == 'json') {
            return new JsonView(['response' => $data]);
        } else {
            return new XmlView($data, 'response');
        }
    }
1007210
public function decode($data, $format, array $context = array())
    {
        $result = null;
        parse_str($data, $result);
        return $result;
    }
490421
protected function dumpRecursive ($levelKey, & $data, & $rawData) {
		if (is_object($data) || is_array($data)) {
			if (strlen($levelKey) > 0) $levelKey .= '.';
			foreach ((array) $data as $key => & $value) {
				$this->dumpRecursive($levelKey . $key, $value, $rawData);
			}
		} else {
			$rawData[] = $levelKey . ' = ' . $this->dumpScalarValue($data);
		}
	}
729063
function printFormatted(string $format): int {
		$args = func_get_args ();
		$s = call_user_func_array ( 'sprintf', $args );
		return $this->write ( $s );
	}
453079
public function serialize($data, $format = 'json')
    {
        $jsonContent = $this->getJmsSerializer()->serialize($data, $format);

        return $jsonContent;
    }
342046
public function paramTag($text, &$data, &$root)
    {
        $explode = preg_split('/[ \t]+/', $text);
        $type = array_shift($explode);
        if ($type) {
            $this->_var = trim(array_shift($explode), '$');
            if ($this->_var) {
                $data['parameters'][$this->_var]['type'] = $type;
            } else {
                $count = isset($data['parameters']) ? count($data['parameters']) : 0;
                $data['parameters']['__unknown'.$count]['type'] = $type;
            }
            $text = join(' ', $explode);
        }
        if ($text != '') {
            parent::tag('@param', $this->_var.' - '.$text, $root);
        } else {
            parent::tag('@param', NULL, $root);
        }
    }
927973
public static function format_exp($string, $format = null)
	{
		is_null($format) and $format = static::$config['formatting']['exp'];
		return static::format($string, $format);
	}
1255796
public function denormalize($data, $class, $format = null, array $context = array())
    {
        $string = parent::denormalize($data, $class, $format, $context);

        return fopen('data:,'.$string, 'r');
    }
1211103
public function returnTag($text, &$data, &$root)
    {
        $explode = preg_split('/[ \t]+/', $text);
        $data['return'] = array_shift($explode);
        parent::tag('@return', join(' ', $explode), $root);
    }
233874
public function normalize($data, $format = null, array $context = [])
    {
        if ($data instanceof ResourceInterface) {
            $event = new BeforeNormalizationEvent($data, (string) $format, $context);
            $this->eventDispatcher->dispatch(SerializationEvents::BEFORE_NORMALIZATION, $event);
        }

        $countNormalizers = 0;

        if (array_key_exists('normalizers', $context)) {
            $countNormalizers = count($context['normalizers']);
            /** @var NormalizerInterface[] $normalizers */
            $normalizers = array_reverse($context['normalizers']);

            foreach ($normalizers as $normalizer) {
                $this->prepareNormalizer($normalizer);
                array_unshift($this->normalizers, $normalizer);
            }
        }

        try {
            $normalized = parent::normalize($data, $format, $context);
        } finally {
            for ($i = 0; $i < $countNormalizers; $i++) {
                array_shift($this->normalizers);
            }
        }

        if ($data instanceof ResourceInterface) {
            $event = new AfterNormalizationEvent($data, $normalized, (string) $format, $context);
            $this->eventDispatcher->dispatch(SerializationEvents::AFTER_NORMALIZATION, $event);
        }

        return $normalized;
    }
240170
public function validate($name, $data, $format = null)
    {
        if (!is_string($data) && !is_array($data)) {
            throw new Exception("propriedade [ {$name} ] é inválida para tipo [ json ] definido no schema", 400);
        }

        $data = $this->encode($name, $data);

        if ($format) {
            $data = self::applyFormat($format, $data);
        }

        return (string)$data;
    }
284603
public static function siretToSiren($siret, bool $format = false): string
    {
        $value = (string) (int) $siret;
        if (!self::isSiret($value)) {
            return '';
        }
        return $format 
             ? preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3', $value)
             : substr($value, 0, 9);
    }
565671
public function getDataVencimento($format = 'd/m/Y')
    {
        return $this->dataVencimento instanceof Carbon
        ? $format === false ? $this->dataVencimento : $this->dataVencimento->format($format)
        : null;
    }
905117
protected static function buildTree(&$data, $rootID = 0)
    {
        $tree = [];

        foreach ($data as $id => $node) {
            if ($node->parentId == $rootID) {
                unset($data[$id]);
                $node->children = self::buildTree($data, $node->id);
                $tree[] = $node;
            }
        }

        return $tree;
    }