fix: strongly type symbol for market data and quote

This commit is contained in:
hackerESQ
2025-01-28 19:35:15 -06:00
parent d23d28afd8
commit 399858d09b
6 changed files with 38 additions and 16 deletions
+11 -3
View File
@@ -26,7 +26,15 @@ class YahooMarketData implements MarketDataInterface
public function exists(string $symbol): bool
{
return $this->quote($symbol)->isNotEmpty();
try {
$this->quote($symbol);
return true;
} catch (\Throwable $e) {
return false;
}
}
public function quote(string $symbol): Quote
@@ -34,8 +42,8 @@ class YahooMarketData implements MarketDataInterface
$quote = $this->client->getQuote($symbol);
if (empty($quote)) {
return collect();
if (is_null($quote)) {
throw new \Exception('Symbol ('.$symbol.') does not exist');
}
return new Quote([