Examples for presentation.
This commit is contained in:
25
sources/Example/Good/VATCalculator.php
Normal file
25
sources/Example/Good/VATCalculator.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Example\Good;
|
||||
|
||||
class VATCalculator
|
||||
{
|
||||
private float $vat;
|
||||
|
||||
/**
|
||||
* @param float $vat
|
||||
*/
|
||||
public function __construct(float $vat)
|
||||
{
|
||||
$this->vat = $vat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product[] $products
|
||||
*/
|
||||
public function applyVat(array $products) : void {
|
||||
foreach ($products as $product) {
|
||||
$product->setPrice( $product->price * (1+$this->vat/100) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user