Skip to content
Permalink
Browse files

add an interface, make class final

  • Loading branch information
matthieu-rolland committed Aug 21, 2019
1 parent 3962f1e commit 9b4d58c91eec8736c4324dda92959d058d2199ac
@@ -27,25 +27,21 @@
namespace PrestaShop\PrestaShop\Core\Localization\CLDR;
use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecisionInterface;
/**
* Will calculate the computing precision (fraction digits number used for computations) that should
* be used for a given display precision.
* {@inheritdoc}
*/
class ComputingPrecision
final class ComputingPrecision implements ComputingPrecisionInterface
{
private $multiplier = 3;
const MULTIPLIER = 3;
/**
* Number of decimal digits to take into account when computing values
* for a given display precision
*
* @var int
*
* @return int
* {@inheritdoc}
*/
public function getPrecision(int $displayPrecision)
{
$computingPrecision = $displayPrecision * $this->multiplier;
$computingPrecision = $displayPrecision * self::MULTIPLIER;
return ($computingPrecision < 2) ? 2 : $computingPrecision;
}
@@ -0,0 +1,44 @@
<?php
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\PrestaShop\Core\Localization\CLDR;
/**
* Will calculate the computing precision (fraction digits number used for computations) that should
* be used for a given display precision.
*/
interface ComputingPrecisionInterface
{
/**
* Number of decimal digits to take into account when computing values
* for a given display precision
*
* @var int
*
* @return int
*/
public function getPrecision(int $displayPrecision);
}

0 comments on commit 9b4d58c

Please sign in to comment.
You can’t perform that action at this time.