<?php namespace Lc\CaracoleBundle\Solver\Config; use Lc\CaracoleBundle\Model\Config\UnitInterface; class UnitSolver { public function getWeight(UnitInterface $unit, float $quantityProduct, ?float $quantity) { if ($quantity) { return ($quantityProduct / $unit->getCoefficient()) * $quantity; } else { return 0; } } }