Formata uma entrada de log gerada pelo AuditableBehavior para fácil
visualização na view, baseada nas configurações do helper.

@param array $data
@param int $type

@return string
160922
public function format($data, $type)
	{
		$func = 'unserialize';

		if (is_callable(AuditableConfig::$unserialize)) {
			$func = AuditableConfig::$unserialize;
		}

		$data = call_user_func($func, $data);

		$placeHolders = array();
		$prepend = __d('auditable', $this->settings['formats']['prepend']) . ' ';
		$pospend = ' ' . __d('auditable', $this->settings['formats']['pospend']);
		$humanDiff = '';
		$action = $this->typesEnum[$type];
		$actionMsg = __d('auditable', $this->settings['formats'][$action]);

		switch ($type) {
			case 2:
				$placeHolders['action'] = __d('auditable', 'modified');

				foreach ($data as $field => $changes) {
					$humanDiff .= $prepend . String::insert($actionMsg, array('field' => $field, 'old' => $changes['old'], 'new' => $changes['new'])) . $pospend;
				}

				break;

			case 1:
				$placeHolders['action'] = __d('auditable', 'created');

			case 3:
				if (!isset($placeHolders['action'])) {
					$placeHolders['action'] = __d('auditable', 'deleted');
				}

				foreach ($data as $field => $value) {
					$humanDiff .= $prepend . String::insert($actionMsg, compact('field', 'value')) . $pospend;
				}

				break;

			default:
				$placeHolders['action'] = __d('auditable', 'undefined');
				$humanDiff .= __d('auditable', 'nothing changed');
				break;
		}

		$placeHolders['data'] = $humanDiff;

		$msg = String::insert(__d('auditable', $this->settings['formats']['general']), $placeHolders);

		return $msg;
	}
1368087
public function cleanParamsForLog($data)
    {
        foreach ($data as $key => &$value) {
            if (in_array($key, $this->obfuscationFields)) {
                $value = self::OBFUSCATION_STRING;
            }

            if (in_array($key, $this->removeFields)) {
                $value = self::REMOVED_STRING;
            }
        }

        return $data;
    }
927012
public function generateInput($type, array $data)
	{
		$class = $this->getElementInstance($type);

		if (array_key_exists('attributes', $data))
		{
			$class->setAttributes($data['attributes']);
		}

		if (array_key_exists('content', $data))
		{
			$class->setContents(
				  $this->generate($data['content'])
			);
		}

		if (array_key_exists('name', $data))
		{
			$class->setName($data['name']);
		}

		if (array_key_exists('value', $data))
		{
			$class->setValue($data['value']);
		}

		if (array_key_exists('label', $data))
		{
			$class->setLabel($data['label']);
		}

		return $class;
	}
164715
public static function log($type, $source): void
    {
        if (
            (!($source instanceof \stdClass) && $type === self::TYPE_EXCEPTION) ||
            (!($source instanceof JsonRpcRequest) && \in_array($type, [self::TYPE_REQUEST, self::TYPE_RESPONSE], true))
        ) {
            return;
        }

        /** @var JsonRpcRequest $jsonRpcRequest */
        $jsonRpcRequest = app('JsonRpcRequest');
        $hideIndices = !empty($jsonRpcRequest->controller->hideDataLog) ? $jsonRpcRequest->controller->hideDataLog : false;
        $method = !empty($jsonRpcRequest->method) ? $jsonRpcRequest->method : 'Unknown';

        switch ($type) {
            case self::TYPE_REQUEST:
                $logLevel = 'info';
                $message = 'Request';
                $context = !empty($source->call) ? (array)$source->call : [];
                break;

            case self::TYPE_RESPONSE:
                $logLevel = 'info';
                $message = sprintf('Successful request to method "%s" (id-%s) with params: ', $source->method, $source->id);
                $context = !empty($source->call) ? (array)$source->call : [];
                break;

            case self::TYPE_EXCEPTION:
                $logLevel = 'error';
                $message = sprintf('JsonRpcException %d: %s',
                    isset($source->code) ? $source->code : 0,
                    !empty($source->message) ? $source->message : '');
                $context = !empty($jsonRpcRequest->call) ? (array)$jsonRpcRequest->call : [];
                break;

            default:
                $logLevel = 'info';
                $message = 'No log type specified';
                $context['params'] = [];
                break;
        }

        $hideDataRules = !empty($hideIndices[$type][$method])
            ? $hideIndices[$type][$method]
            : false;

        $hideData = function (&$item, $key, $rules) {
            if (\in_array($key, $rules, true)) {
                $item = '****';
            }
        };

        if ($hideDataRules && !empty($context['params'])) {
            array_walk($context['params'], $hideData, $hideDataRules);
        }

        Log::channel(config('jsonrpc.log_channel'))
            ->$logLevel($message, $context);

    }
228556
public function pack(string $type, array $data): string
    {
        $data = [
            'pipeType' => $type,
            'message'  => $data,
        ];

        return JsonHelper::encode($data, JSON_UNESCAPED_UNICODE);
    }
850729
public function getParamFormat(string $type): string
    {
        return ltrim(($this->containerPrefix.'.entity.'.$this->entityName.'.'.$type), '.');
    }
5925
public static function response($data, $type = self::FORMAT_XML)
    {
        if (is_string($data) && strlen($data) === 0) {
            return true; // Many operations return an empty string for success
        }
        switch ($type) {
            case static::FORMAT_XML:
                return AbstractResponse::fromXml($data);
            case static::FORMAT_JSON:
                return AbstractResponse::fromJson($data);
        }
        throw new InvalidArgumentException("Type must be 'xml' or 'json'");
    }
663278
final protected function _log($type, array $args)
	{
		// nothing passed in, don't do anything
		if (count($args) === 0 && $type !== self::GROUP_END) {
			return;
		}
		$this->_processed = array();

		$logs = array_map([$this, '_convert'], $args);
		$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
		$backtrace_message = 'unknown';
		$backtrace = end($backtrace);
		if (isset($backtrace['file'], $backtrace['line'])) {
			$backtrace_message = $this->_formatLocation(
				$backtrace['file'],
				$backtrace['line']
			);
		}
		$this->_addRow($logs, $backtrace_message, $type);
	}
1136291
public function json($data, $type = 'json') {
        switch (strtolower($type)) {
            case 'xml':
                return Factory::response()->xml($data);
            case 'jsonp':
                return Factory::response()->jsonp($data);
        }
        return Factory::response()->json($data);
    }
559368
public function sanitize($data, $type, $base = '')
	{
		try
		{
			return $this->sanitize->sanitize($data, $type, $base);
		}
		catch (SimplePie_Exception $e)
		{
			if (!$this->enable_exceptions)
			{
				$this->error = $e->getMessage();
				$this->registry->call('Misc', 'error', array($this->error, E_USER_WARNING, $e->getFile(), $e->getLine()));
				return '';
			}

			throw $e;
		}
	}
1231048
public static function buildQuery(Array $data, String $separator = '/', String $type = 'none') : String
    {
        $query = NULL;

        foreach( $data as $key => $value )
        {
            if( is_numeric($key) )
            {
                $query .= $value . '/';
            }
            else
            {
                $query .= $key . '/' . $value . '/';
            }
        }

        return self::_addFix($query, $type);
    }
243256
public function output($type = 'array')
    {
        $debug = Arrays\RemoveElement::first($this->debug, 2);
        $debug = array_merge([(array) $this->current()], $debug);

        if( is_numeric($type) )
        {
            return (object) ( $debug[$type] ?? $this->_default() );
        }
        elseif( $type === 'array' )
        {
            return $debug;
        }
        elseif( $type === 'string' )
        {
            return output($debug, [], true);
        }
        else
        {
            return $this->_default();
        }
    }
1247119
public function visitArray(array $data, array $type)
    {
        \array_push($this->dataStack, $data);

        $rs = isset($type['params'][1]) ? new \ArrayObject() : [];

        $isList = isset($type['params'][0]) && !isset($type['params'][1]);

        $elType = $this->getElementType($type);
        foreach ($data as $k => $v) {
            try {
                $v = $this->navigator->accept($v, $elType);
            } catch (NotAcceptableException $e) {
                continue;
            }

            if ($isList) {
                $rs[] = $v;
            } else {
                $rs[$k] = $v;
            }
        }

        \array_pop($this->dataStack);
        return $rs;
    }
711340
protected function writeMsgId(array $entry, $type = 'msgid')
    {
        $result = '';

        if (!isset($entry[$type])) {
            return $result;
        }

        $result .= $type . ' ';
        if (is_array($entry[$type])) {
            foreach ($entry[$type] as $id) {
                $result .= $this->cleanExport($id) . "\n";
            }
        } else {
            $result .= $this->cleanExport($entry[$type]) . "\n";
        }

        return $result;
    }
773526
public function _log($string,$type='info') {
        if($this->config['debug']){
            $string = $this->getLogTime().": ".$string;
        }
        if($type=='info')
            $this->log->addInfo($string);
        elseif($type=='warning')
            $this->log->addWarning($string);
        elseif($type=='error')
            $this->log->addError($string);
    }
607879
public function column( $type )
    {
        $classPrefix = __CLASS__ . '\\Type\\';

        if ( is_string( $type ) &&
             class_exists( $classPrefix . ucfirst( $type ) ) )
        {
            $type = ucfirst( $type );
            $args = func_get_args();
            array_shift( $args );
        }
        else if ( is_callable( $type ) )
        {
            $args = func_get_args();
            $type = static::CALLBACK;
        }
        else
        {
            $type = ucfirst( (string) $type );
            $args = func_get_args();
            array_shift( $args );
        }

        $class = $classPrefix . $type;

        if ( ! class_exists( $class ) )
        {
            throw new \LogicException( 'RowSet-type does not exists: ' . $class );
        }

        $reflection = new \ReflectionClass( $class );
        $result     = $reflection->newInstanceArgs( $args );

        if ( $result instanceof HelperInterface )
        {
            $result->setView( $this->getView() );
        }

        return $result;
    }
463385
protected function formatType($type)
    {
        if (preg_match('/^(?:(.*)\.)?_(.*)$/', $type, $matches)) {
            if ($matches[1] !== '') {
                return sprintf("%s.%s[]", $matches[1], $matches[2]);
            } else {
                return $matches[2].'[]';
            }
        } else {
            return $type;
        }
    }