diff --git a/composer.json b/composer.json index 1e5acaa..548aec4 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require": { "php": "^7.2.5|^8.0", "ext-json": "*", - "andrey-helldar/support": "2.8.0", + "andrey-helldar/support": "^2.16.2", "symfony/http-foundation": "^4.0|^5.0" }, "require-dev": { diff --git a/src/Parsers/Exception.php b/src/Parsers/Exception.php index a35b0fa..1082265 100644 --- a/src/Parsers/Exception.php +++ b/src/Parsers/Exception.php @@ -3,6 +3,7 @@ namespace Helldar\ApiResponse\Parsers; use Exception as BaseException; +use Helldar\Support\Facades\Helpers\Call; use Helldar\Support\Facades\Helpers\Instance; use Throwable; @@ -28,11 +29,7 @@ public function getStatusCode(): int return $this->status_code; } - if ($code = Instance::callWhen($this->data, ['getStatusCode', 'getCode'], 400)) { - return $code; - } - - return parent::getStatusCode(); + return Call::runMethods($this->data, ['getStatusCode', 'getCode']) ?: 400; } /** @@ -41,7 +38,7 @@ public function getStatusCode(): int protected function getThrowableContent() { return Instance::of($this->data, [BaseException::class, Throwable::class]) - ? Instance::callWhen($this->data, ['getOriginalContent', 'getContent', 'getResponse', 'getMessage']) + ? Call::runMethods($this->data, ['getOriginalContent', 'getContent', 'getResponse', 'getMessage']) : null; } }