Skip to content

Commit

Permalink
Fix null arguments in timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
marekskopal committed Feb 11, 2024
1 parent 6d04102 commit 21645e5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
24 changes: 14 additions & 10 deletions src/Dto/CoreData/TimeSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public static function fromJson(string $json): self
* meta: array{
* symbol: string,
* interval: string,
* currency: string,
* exchange_timezone: string,
* exchange: string,
* mic_code: string,
* currency?: string,
* exchange_timezone?: string,
* exchange?: string,
* mic_code?: string,
* currency_base?: string,
* currency_quote?: string,
* type: string,
* },
* values: list<array{
Expand All @@ -30,7 +32,7 @@ public static function fromJson(string $json): self
* high: string,
* low: string,
* close: string,
* volume: string,
* volume?: string,
* }>,
* status: string,
* } $responseContents
Expand All @@ -45,10 +47,12 @@ public static function fromJson(string $json): self
* meta: array{
* symbol: string,
* interval: string,
* currency: string,
* exchange_timezone: string,
* exchange: string,
* mic_code: string,
* currency?: string,
* exchange_timezone?: string,
* exchange?: string,
* mic_code?: string,
* currency_base?: string,
* currency_quote?: string,
* type: string,
* },
* values: list<array{
Expand All @@ -57,7 +61,7 @@ public static function fromJson(string $json): self
* high: string,
* low: string,
* close: string,
* volume: string,
* volume?: string,
* }>,
* status: string,
* } $data
Expand Down
30 changes: 18 additions & 12 deletions src/Dto/CoreData/TimeSeriesMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
public function __construct(
public string $symbol,
public string $interval,
public string $currency,
public string $exchangeTimezone,
public string $exchange,
public string $micCode,
public ?string $currency,
public ?string $exchangeTimezone,
public ?string $exchange,
public ?string $micCode,
public ?string $currencyBase,
public ?string $currencyQuote,
public string $type,
) {
}
Expand All @@ -21,10 +23,12 @@ public function __construct(
* @param array{
* symbol: string,
* interval: string,
* currency: string,
* exchange_timezone: string,
* exchange: string,
* mic_code: string,
* currency?: string,
* exchange_timezone?: string,
* exchange?: string,
* mic_code?: string,
* currency_base?: string,
* currency_quote?: string,
* type: string,
* } $data
*/
Expand All @@ -33,10 +37,12 @@ public static function fromArray(array $data): self
return new self(
symbol: $data['symbol'],
interval: $data['interval'],
currency: $data['currency'],
exchangeTimezone: $data['exchange_timezone'],
exchange: $data['exchange'],
micCode: $data['mic_code'],
currency: $data['currency'] ?? null,
exchangeTimezone: $data['exchange_timezone'] ?? null,
exchange: $data['exchange'] ?? null,
micCode: $data['mic_code'] ?? null,
currencyBase: $data['currency_base'] ?? null,
currencyQuote: $data['currency_quote'] ?? null,
type: $data['type'],
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Dto/CoreData/TimeSeriesValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
public string $high,
public string $low,
public string $close,
public string $volume,
public ?string $volume,
) {
}

Expand All @@ -25,7 +25,7 @@ public function __construct(
* high: string,
* low: string,
* close: string,
* volume: string,
* volume?: string,
* } $data
*/
public static function fromArray(array $data): self
Expand All @@ -36,7 +36,7 @@ public static function fromArray(array $data): self
high: $data['high'],
low: $data['low'],
close: $data['close'],
volume: $data['volume'],
volume: $data['volume'] ?? null,
);
}
}

0 comments on commit 21645e5

Please sign in to comment.