Skip to content

Commit

Permalink
Merge pull request #4 from NystronSolar/ClientInterfaces
Browse files Browse the repository at this point in the history
fix: add Numeric String Doc Block Annotaion for Energy Class
  • Loading branch information
TheDevick authored Jun 2, 2023
2 parents 5c9739b + 85a8758 commit fdc547f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Entity/Energy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@

use NystronSolar\GrowattApi\Client\ApiClientInterface;

/**
* @property numeric-string $generation
*
* @method numeric-string getGeneration()
*/
class Energy
{
private \DateTimeInterface $date;

private string $generation;

/**
* @param numeric-string $generation
*/
public function __construct(string $date, string $generation)
{
$this->generation = $generation;
Expand Down
4 changes: 2 additions & 2 deletions src/Response/ApiPlantHistoryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public static function generate(ResponseInterface $httpResponse): ApiPlantHistor
$generation = $rawEnergy->energy;
if (
!is_string($date)
|| !is_string($generation)
|| !is_numeric($generation)
) {
return false;
}

$energy = new Energy($date, $generation);
$energy = new Energy($date, (string) $generation);

$energies[] = $energy;
}
Expand Down

0 comments on commit fdc547f

Please sign in to comment.