mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 07:13:11 +08:00
Replaced all FQ global function and constants by explicit imports
This commit is contained in:
@@ -3,7 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Exception;
|
||||
|
||||
use Throwable;
|
||||
use Zend\InputFilter\InputFilterInterface;
|
||||
use function is_array;
|
||||
use function print_r;
|
||||
use function sprintf;
|
||||
|
||||
class ValidationException extends RuntimeException
|
||||
{
|
||||
@@ -16,7 +20,7 @@ class ValidationException extends RuntimeException
|
||||
string $message = '',
|
||||
array $invalidElements = [],
|
||||
int $code = 0,
|
||||
\Throwable $previous = null
|
||||
Throwable $previous = null
|
||||
) {
|
||||
$this->invalidElements = $invalidElements;
|
||||
parent::__construct($message, $code, $previous);
|
||||
@@ -27,7 +31,7 @@ class ValidationException extends RuntimeException
|
||||
* @param \Throwable|null $prev
|
||||
* @return ValidationException
|
||||
*/
|
||||
public static function fromInputFilter(InputFilterInterface $inputFilter, \Throwable $prev = null): self
|
||||
public static function fromInputFilter(InputFilterInterface $inputFilter, Throwable $prev = null): self
|
||||
{
|
||||
return static::fromArray($inputFilter->getMessages(), $prev);
|
||||
}
|
||||
@@ -37,10 +41,10 @@ class ValidationException extends RuntimeException
|
||||
* @param \Throwable|null $prev
|
||||
* @return ValidationException
|
||||
*/
|
||||
public static function fromArray(array $invalidData, \Throwable $prev = null): self
|
||||
public static function fromArray(array $invalidData, Throwable $prev = null): self
|
||||
{
|
||||
return new self(
|
||||
\sprintf(
|
||||
sprintf(
|
||||
'Provided data is not valid. These are the messages:%s%s%s',
|
||||
PHP_EOL,
|
||||
self::formMessagesToString($invalidData),
|
||||
@@ -56,10 +60,10 @@ class ValidationException extends RuntimeException
|
||||
{
|
||||
$text = '';
|
||||
foreach ($messages as $name => $messageSet) {
|
||||
$text .= \sprintf(
|
||||
$text .= sprintf(
|
||||
"\n\t'%s' => %s",
|
||||
$name,
|
||||
\is_array($messageSet) ? \print_r($messageSet, true) : $messageSet
|
||||
is_array($messageSet) ? print_r($messageSet, true) : $messageSet
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user