From b69eb053a13559f81ed2d4c6e684fde7e1cca172 Mon Sep 17 00:00:00 2001 From: Richard Muvirimi Date: Fri, 3 Nov 2023 11:00:58 +0200 Subject: [PATCH] Change status message character case --- app/Traits/ScrapesRates.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Traits/ScrapesRates.php b/app/Traits/ScrapesRates.php index 897155d..79c33e1 100644 --- a/app/Traits/ScrapesRates.php +++ b/app/Traits/ScrapesRates.php @@ -32,7 +32,7 @@ public function scrape(): void return; } - $site = ''.$site.''; + $site = '' . $site . ''; Cache::set($this->source_url, $site, CarbonInterval::minutes(30)); } @@ -49,7 +49,7 @@ private function getHtmlContent(): string { $headers = [ - 'Authorization' => 'Bearer '.env('SCRAPPY_TOKEN'), + 'Authorization' => 'Bearer ' . env('SCRAPPY_TOKEN'), ]; $body = [ @@ -67,7 +67,7 @@ private function getHtmlContent(): string $client = new Client($options); - $response = $client->post(env('SCRAPPY_SERVER').'/scrape', [ + $response = $client->post(env('SCRAPPY_SERVER') . '/scrape', [ 'headers' => $headers, 'form_params' => $body, ]); @@ -91,7 +91,7 @@ private function getUserAgent(): string { $agent = Cache::get('user-agent'); - if (! $agent) { + if (!$agent) { $agent = env('USER_AGENT'); $agent = preg_replace('/headless/i', '', $agent); @@ -116,7 +116,7 @@ private function parseHtml(string $html): void $converter = new CssSelectorConverter(); $selector = $this->rate_selector; - if (! $this->isXpath($selector)) { + if (!$this->isXpath($selector)) { $selector = $converter->toXPath($selector); } @@ -133,22 +133,22 @@ private function parseHtml(string $html): void } $selector = $this->rate_updated_at_selector; - if (! $this->isXpath($selector)) { + if (!$this->isXpath($selector)) { $selector = $converter->toXPath($selector); } //date $this->rate_updated_at = $this->cleanDate($crawler->filterXPath($selector)->text(), $this->source_timezone); $this->status = true; - $this->statusMessage = ''; + $this->status_message = ''; } else { $this->status = false; - $this->statusMessage = 'Rate is an empty string.'; + $this->status_message = 'Rate is an empty string.'; } } catch (Exception $e) { $this->status = false; - $this->statusMessage = $e->getMessage(); + $this->status_message = $e->getMessage(); } finally { $this->save(); } @@ -179,7 +179,7 @@ private function cleanRate(string $value, string $locale): float */ $amount = preg_replace('/(\d)\s+(\d)/', '$1$2', $amount); - if (! is_numeric($amount)) { + if (!is_numeric($amount)) { // separate alpha characters from numeric $amount = preg_replace('/([^0-9,.]*)([0-9,.]+)([^0-9,.]*)/i', '$1 $2 $3', $amount); @@ -308,7 +308,7 @@ private function cleanDate(string $value, string $timezone): Carbon $months[] = strtolower(DateTime::createFromFormat('n', $i)->format('F')); } - $regex = "/\b(?!(".implode('|', $months).'|(\w[0-9][a-z])))(\w*[a-z]+[^\s]*|(\w[^\D\d\w]))/i'; + $regex = "/\b(?!(" . implode('|', $months) . '|(\w[0-9][a-z])))(\w*[a-z]+[^\s]*|(\w[^\D\d\w]))/i'; $rawDate = preg_replace($regex, '', $rawDate);