Apply "SlevomatCodingStandard.ControlStructures.ControlStructureSpacing"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-09 13:17:02 +01:00
parent 3920f5a0e6
commit 750cfa217a
No known key found for this signature in database
GPG key ID: 221E9281655813A6
3 changed files with 16 additions and 3 deletions

View file

@ -24,6 +24,11 @@ use Respect\Validation\Rules\AbstractRule;
*/
class PlIdentityCard extends AbstractRule
{
private const ASCII_CODE_0 = 48;
private const ASCII_CODE_7 = 55;
private const ASCII_CODE_9 = 57;
private const ASCII_CODE_A = 65;
/**
* {@inheritdoc}
*/
@ -37,15 +42,15 @@ class PlIdentityCard extends AbstractRule
$weightedSum = 0;
for ($i = 0; $i < 9; ++$i) {
$code = ord($input[$i]);
if ($i < 3 && $code <= 57) { // 57 is "9"
if ($i < 3 && $code <= self::ASCII_CODE_9) {
return false;
}
if ($i > 2 && $code >= 65) { // 65 is "A"
if ($i > 2 && $code >= self::ASCII_CODE_A) {
return false;
}
$difference = $code <= 57 ? 48 : 55; // 48 is "0"
$difference = $code <= self::ASCII_CODE_9 ? self::ASCII_CODE_0 : self::ASCII_CODE_7;
$weightedSum += ($code - $difference) * $weights[$i];
}

View file

@ -43,6 +43,7 @@ class Zend extends AbstractRule
{
if ($validator instanceof ZendValidator) {
$this->zendValidator = $validator;
return;
}

View file

@ -46,6 +46,13 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition" />
<rule ref="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit" />
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />