for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Waredesk\Mappers;
use Waredesk\Collections\Products\Variants;
use Waredesk\Mappers\Product\VariantsMapper;
use Waredesk\Models\Product;
use DateTime;
class ProductMapper
{
public function map(Product $product, array $data): Product
foreach ($data as $key => $value) {
switch ($key) {
case 'id':
$product->setId((int)$value);
break;
case 'images':
$product->setImages($value);
case 'variants':
$product->setVariants((new VariantsMapper())->map(new Variants(), $value));
case 'name':
$product->setName($value);
case 'description':
$product->setDescription($value);
case 'notes':
$product->setNotes($value);
case 'creation_datetime':
$product->setCreationDatetime(new DateTime($value));
case 'modification_datetime':
$product->setModificationDatetime(new DateTime($value));
}
return $product;