for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Waredesk\Mappers\Product\Variant;
use DateTime;
use Waredesk\Models\Product\Variant\Price;
class PriceMapper
{
public function map(Price $price, $data): Price
$finalData = [];
foreach ($data as $key => $value) {
switch ($key) {
case 'price':
$finalData['price'] = (int)$value;
break;
case 'creation':
$finalData['creation'] = new DateTime($value);
case 'modification':
$finalData['modification'] = new DateTime($value);
default:
$finalData[$key] = $value;
}
$price->reset($finalData);
return $price;