Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Dec 10, 2023
1 parent 6ad961d commit ec7ebfc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Rules/Postalcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Postalcode extends AbstractRule implements DataAwareRule
*
* @var array
*/
protected $data;
protected $data = [];

/**
* Create a new rule instance with allowed countrycodes
Expand Down Expand Up @@ -78,18 +78,6 @@ public function isValid(mixed $value): bool
return false;
}

protected function getCountryCodes(): array
{
if (count($this->countrycodes) == 0) {
// return country code by reference
if (is_array($this->data) && array_key_exists($this->reference, $this->data)) {
return $this->data[$this->reference];
}
}

return $this->countrycodes;
}

/**
* Return regex patterns for allowed country codes
*
Expand All @@ -107,6 +95,18 @@ protected function getPatterns(): array
});
}

protected function getCountryCodes(): array
{
if (count($this->countrycodes) == 0) {
// return country code by reference
if (is_array($this->data) && array_key_exists($this->reference, $this->data)) {
return [$this->data[$this->reference]];
}
}

return $this->countrycodes;
}

/**
* Return regex pattern for postal code of current country code
*
Expand Down

0 comments on commit ec7ebfc

Please sign in to comment.