Skip to content

Commit

Permalink
Add multiplier method
Browse files Browse the repository at this point in the history
  • Loading branch information
Holicz committed Mar 31, 2020
1 parent d35da25 commit a6d9909
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ composer require holicz/pvgis
* PHP >= 7.4

# Usage

## Basic usage
```php
<?php

Expand All @@ -29,3 +31,11 @@ foreach ($electricityProduction->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);
```
16 changes: 16 additions & 0 deletions src/Model/ElectricityProduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/Model/MonthlyProduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a6d9909

Please sign in to comment.