Examples for presentation.
This commit is contained in:
29
sources/Example/Bad/CalculatorService.php
Normal file
29
sources/Example/Bad/CalculatorService.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Example\Bad;
|
||||
|
||||
class CalculatorService
|
||||
{
|
||||
private float $vatPercent;
|
||||
private APIService $apiService;
|
||||
|
||||
public function __construct(float $vatPercent, APIService $apiService)
|
||||
{
|
||||
$this->vatPercent = $vatPercent;
|
||||
$this->apiService = $apiService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Product[]
|
||||
*/
|
||||
public function getProducts(string $requestData) : array {
|
||||
$products = $this->apiService->getProducts($requestData);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$product->price = $product->price * ( 1 + $this->vatPercent);
|
||||
}
|
||||
|
||||
return $products;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user