Applied symplify rules to codebase.

This commit is contained in:
Jan Böhmer 2020-01-05 22:49:00 +01:00
parent 2f20d90041
commit 388e847b17
136 changed files with 1370 additions and 789 deletions

View file

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace App\Services;
use App\Entity\Parts\MeasurementUnit;
use InvalidArgumentException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -48,12 +49,12 @@ class AmountFormatter
*
* @return string The formatted string
*
* @throws \InvalidArgumentException thrown if $value is not numeric
* @throws InvalidArgumentException thrown if $value is not numeric
*/
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
{
if (! is_numeric($value)) {
throw new \InvalidArgumentException('$value must be an numeric value!');
throw new InvalidArgumentException('$value must be an numeric value!');
}
$value = (float) $value;
@ -117,7 +118,9 @@ class AmountFormatter
return '';
},
'decimals' => 2,
'error_mapping' => ['.' => 'value'],
'error_mapping' => [
'.' => 'value',
],
]);
$resolver->setAllowedTypes('decimals', 'int');