Minor refactoring

This commit is contained in:
Meritoo
2017-12-21 20:41:12 +01:00
parent 8bb529b88d
commit 5aaf7cde72
2 changed files with 9 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ class Bundle
* Returns path to view / template of given bundle * Returns path to view / template of given bundle
* *
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template" * @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
* @param string $bundleName Name of the bundle, e.g. "MyExtraBundle" * @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
* @param string $extension (optional) Extension of the view / template * @param string $extension (optional) Extension of the view / template
* @return string|null * @return string|null
*/ */

View File

@@ -62,14 +62,14 @@ class Regex
} }
/** /**
* Returns information if given tax ID (in polish: NIP) is valid * Returns information if given tax ID is valid (in Poland it's named "NIP")
* *
* @param string $taxidString Tax ID (NIP) string * @param string $taxIdString Tax ID (NIP) string
* @return bool * @return bool
*/ */
public static function isValidTaxid($taxidString) public static function isValidTaxId($taxIdString)
{ {
if (!empty($taxidString)) { if (!empty($taxIdString)) {
$weights = [ $weights = [
6, 6,
5, 5,
@@ -81,15 +81,15 @@ class Regex
6, 6,
7, 7,
]; ];
$taxid = preg_replace('/[\s-]/', '', $taxidString); $taxId = preg_replace('/[\s-]/', '', $taxIdString);
$sum = 0; $sum = 0;
if (10 == strlen($taxid) && is_numeric($taxid)) { if (10 == strlen($taxId) && is_numeric($taxId)) {
for ($x = 0; $x <= 8; ++$x) { for ($x = 0; $x <= 8; ++$x) {
$sum += $taxid[$x] * $weights[$x]; $sum += $taxId[$x] * $weights[$x];
} }
if ((($sum % 11) % 10) == $taxid[9]) { if ((($sum % 11) % 10) == $taxId[9]) {
return true; return true;
} }
} }