fromHttp(); } public function __construct($url, $response, $title, $options) { $this->url = $url; $this->response = $response; $this->title = $title; $this->options = $options; } public function fromHttp() { if (is_null($level = $this->level())) { return $this; } Log::{$level}($this->title, array_merge([ 'url' => $this->url, 'response' => $this->response->body(), 'json' => $this->response->json(), ], $this->options)); } public function level() { return in_array($this->response->status(), $this->errors) || false == $this->response['success'] ? 'error' : null; } }