Construye el mensaje de la excepción

@param mixed  $data
@param string $reason

@return string
506404
private static function buildMessage($data, string $reason): string
    {
        $template = self::getTemplate();

        $message = beautify_parse($template, [
            'value' => $data,
            'not_valid' => 'NOT VALID',
            'reason' => $reason,
        ]);

        return $message;
    }
984832
private function explainOneOf($data, $explanation, $currentPath, $isArray = false)
    {
        $explanation->addOneOf(array_map(function ($oneOf) use ($currentPath, $isArray) {
            return $this->explainSchema($oneOf, null, $currentPath, $isArray);
        }, $data->oneOf), 'an auto generated descr', true);
    }
327640
protected function formatMessage(array $data = [])
    {
        $params = array_merge($this->message, $data);

        foreach ($params as $key => $value) {
            if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) {
                throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
            }

            $params[$key] = empty($value) ? $this->message[$key] : $value;
        }

        $params['data'] = $this->formatData($params['data'] ?? []);

        return $params;
    }
869026
public function create($data)
    {
        $descriptor = new NamespaceDescriptor();
        $descriptor->setName($data->getName());
        $descriptor->setFullyQualifiedStructuralElementName($data->getFqsen());
        $namespace = substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1);
        $descriptor->setNamespace($namespace === '' ? '\\' : $namespace);

        return $descriptor;
    }
86694
protected function decodeFileName($data)
    {
        array_shift($data);
        if (count($data) == 1) {
            $name = preg_replace('#.*name\s*\=\s*[\'"]([^\'"]+).*#si', '$1', $data[0]);
        } elseif (count($data) > 1) {
            foreach ($data as $value) {
                if (preg_match(self::FILE_PATTERN, $value, $res)) {
                    $name = $res[3];
                }
            }
        } else {
            return null;
        }

        $tmpFileName = Headers::decodeMimeString($name);
        //TODO не очень хорошее решение, если кто предложит лучше, готов рассмотреть
        // Content-Disposition: attachment; filename*=UTF-8''%D0%B7%D0%B0%D1%8F%D0%B2%D0%BA%D0%B0%20%D0%95%D0%B2%D1%80%D0%BE%D0%94%D0%BE%D0%BD%208%D1%84%D0%B5%D0%B2%D1%802017%2Exls
        if ($tmpFileName === $name) {
            $tmp = explode("''", $name);
            if (count($tmp) > 1) {
                $tmpFileName = urldecode($tmp[1]);
            }
        }

        return $this->toUtf8($tmpFileName);
    }
1314714
function kick(string $reason = '') {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($reason) {
            $this->client->apimanager()->endpoints->guild->removeGuildMember($this->guild->id, $this->id, $reason)->done(function () use ($resolve) {
                $resolve();
            }, $reject);
        }));
    }
616709
public function explainSchema(
      $data,
      $explanation = null,
      $currentPath = '',
      $isArray = false
  ) {
        if (!$explanation) {
            $explanation = new Explanation();
        }
        //parse the json and explain what to do

        if (isset($data->type)) {
            $this->explainObject($data, $explanation, $currentPath, $isArray);
        } elseif (property_exists($data, 'oneOf')) {
            $this->explainOneOf($data, $explanation, $currentPath, $isArray);
        } elseif (property_exists($data, 'allOf')) {
        } elseif (property_exists($data, 'anyOf')) {
        }

        return $explanation;
    }
330407
public function fromRawData($data)
    {
        $secretLength = VarInt::readUnsignedVarInt($data);
        $data = substr($data, $secretLength->getDataLength());

        $secretData = substr($data, 0, $secretLength->getValue());
        $data = substr($data, $secretLength->getValue());

        $verifyLength = VarInt::readUnsignedVarInt($data);
        $data = substr($data, $verifyLength->getDataLength());

        $verifyData = substr($data, 0, $verifyLength->getValue());

        $this->setToken($verifyData)->setSecret($secretData);
    }
704048
public function withStatus($code, $reason = '')
    {
        $code = Validator::checkCode($code);

        if (!is_string($reason) && !method_exists($reason, '__toString')) {
            throw new InvalidArgumentException('ReasonPhrase must be a string');
        }

        $clone = clone $this;
        $clone->code = $code;
        if ($reason === '') {
            $reason = Validator::getCodeMessage($code);
        }

        if ($reason === '') {
            throw new InvalidArgumentException('ReasonPhrase must be supplied for this code');
        }

        $clone->phrase = $reason;

        return $clone;
    }
219317
public function sendMassMessage($data)
    {
        return $this->auth(function () use ($data) {
            if (!is_string($data)) {
                $data = json_encode($data, JSON_UNESCAPED_UNICODE);
            }

            return $this->http->postJson(
                $this->baseUrl . 'cgi-bin/message/mass/send?access_token=' . $this->accessToken,
                $data
            );
        });
    }
783232
private function doXssClean($data)
    {
        if (is_array($data) && count($data)) {
            foreach ($data as $k => &$v) {
                $v = $this->doXssClean($data[$k]);
            }

            return $data;
        }

        if (trim($data) === '') {
            return $data;
        }

        // xss_clean function from Kohana framework 2.3.1
        $data = str_replace(['&amp;', '&lt;', '&gt;'], ['&amp;amp;', '&amp;lt;', '&amp;gt;'], $data);
        $data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
        $data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');

        // Remove any attribute starting with "on" or xmlns
        $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);

        // Remove javascript: and vbscript: protocols
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu',
            '$1=$2nojavascript...', $data);
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu',
            '$1=$2novbscript...', $data);
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u',
            '$1=$2nomozbinding...', $data);

        // Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i',
            '$1>', $data);
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i',
            '$1>', $data);
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu',
            '$1>', $data);

        // Remove namespaced elements (we do not need them)
        $data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);

        do {
            // Remove really unwanted tags
            $old_data = $data;
            $data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i',
                '', $data);
        } while ($old_data !== $data);

        return $data;
    }
1008161
function delete(string $reason = '') {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($reason) {
            $this->client->apimanager()->endpoints->channel->deleteChannelPermission($this->channel->getId(), $this->id, $reason)->then(function () use ($resolve) {
                $resolve();
            }, $reject);
        }));
    }
394345
private function resolveMainLanguageCode($data): string
    {
        if (!$data instanceof ContentUpdateData && !$data instanceof ContentCreateData) {
            throw new InvalidArgumentException(
                '$data',
                'expected type of ContentUpdateData or ContentCreateData'
            );
        }

        return $data->isNew()
            ? $data->mainLanguageCode
            : $data->contentDraft->getVersionInfo()->getContentInfo()->mainLanguageCode;
    }
153100
private function sendGetExportDocRequest($data) {
		switch($this->getMayor()) {
			case 1:
				return $this->getSoapClient()->getExportDocDD($data);
			case 2:
			default:
				return $this->getSoapClient()->getExportDoc($data);
		}
	}
109506
public function xssClean($data)
    {
        // If its empty there is no point cleaning it :\
        if (empty($data)) {
            return $data;
        }

        // Recursive loop for arrays
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->xssClean($data);
            }

            return $data;
        }

        // Fix &entity\n;
        $data = $this->fixEntity($data);

        // Remove any attribute starting with "on" or xmlns
        $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);

        // Remove javascript: and vbscript: protocols
        $data = $this->removeJavaScriptProtocols($data);

        $data = $this->removeVbScriptProtocols($data);

        $data = preg_replace(
            '#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u',
            '$1=$2nomozbinding...',
            $data
        );

        // Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
        $data = $this->fixIe($data);

        // Remove namespaces elements (we do not need them)
        $data = $this->removeNameSpaceElements($data);

        $data = preg_replace($this->sqlReplace, '', $data);

        do {
            // Remove really unwanted tags
            $old_data = $data;
            $data = preg_replace(
                '#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l
                (?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i',
                '',
                $data
            );
        } while ($old_data !== $data);

        return htmlentities($data);
    }
348303
public function create($data)
    {
        $methodDescriptor = new MethodDescriptor();
        $this->mapReflectorToDescriptor($data, $methodDescriptor);

        $this->assembleDocBlock($data->getDocBlock(), $methodDescriptor);
        $this->addArguments($data, $methodDescriptor);
        $this->addVariadicArgument($data, $methodDescriptor);

        return $methodDescriptor;
    }
589374
public function create($data)
    {
        $descriptor = new UsesDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $reference = $data->getReference();

        $descriptor->setReference($reference);

        return $descriptor;
    }