diff --git a/README.md b/README.md index fa7869c..7f28079 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ composer require holicz/pvgis * PHP >= 7.4 # Usage + +## Basic usage ```php getMonthlyProductions() as $monthlyProduction) $monthlyProduction->getProduction(); } ``` + +## Using multiplier +If you for example know that you have six solar panels and the production is 1.86x time more bigger than the PVGIS +result you should use the multiplier method + +```php +$electricityProduction->multiply(1.86); +``` diff --git a/src/Model/ElectricityProduction.php b/src/Model/ElectricityProduction.php index f519cd4..9e8ad10 100644 --- a/src/Model/ElectricityProduction.php +++ b/src/Model/ElectricityProduction.php @@ -25,6 +25,22 @@ public function __clone() $this->monthlyProductions = $monthlyProductions; } + /** + * Method to multiply the results by constant + * Useful if you know how much more powerful your solar panels are than the PVGIS result + * + * @param float $multiplier + */ + public function multiply(float $multiplier): void + { + $this->yearlyProduction = round($this->yearlyProduction * $multiplier, 2); + + foreach ($this->monthlyProductions as $monthlyProduction) { + $monthlyProduction->multiply($multiplier); + } + } + + public function addMonthlyProduction(int $month, float $production): self { $this->monthlyProductions[] = new MonthlyProduction($month, $production); diff --git a/src/Model/MonthlyProduction.php b/src/Model/MonthlyProduction.php index 6a01440..e5669b4 100644 --- a/src/Model/MonthlyProduction.php +++ b/src/Model/MonthlyProduction.php @@ -15,6 +15,11 @@ public function __construct(int $month, float $production) $this->production = $production; } + public function multiply(float $multiplier): void + { + $this->production = round($this->production * $multiplier, 2); + } + public function getMonth(): int { return $this->month;