Skip to content

Commit

Permalink
Merge pull request #27 from Talentify/fix/add-zipcode-validation
Browse files Browse the repository at this point in the history
change method setValue and remove countCharacters from StringUtils
  • Loading branch information
magroski authored Mar 18, 2021
2 parents cbcce5b + b799027 commit 8536997
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Geography/Address/ByCountry/Us/ZipCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
*/
class ZipCode extends PostalCode
{
public function setValue(string $value): void
protected function setValue(string $value): void
{
$value = StringUtils::trimSpacesWisely($value);
$changedValue = StringUtils::removeNonWordCharacters($value);
$characters = StringUtils::countCharacters($changedValue);
$characters = strlen($changedValue);

if ($characters == 4) {
$value = '0' . $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Geography/Address/PostalCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(string $value)
$this->setValue($value);
}

public function setValue(string $value) : void
protected function setValue(string $value) : void
{
$normalized = StringUtils::trimSpacesWisely($value);
if (empty($normalized)) {
Expand Down
5 changes: 0 additions & 5 deletions src/StringUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,4 @@ public static function convertCaseToLower(string $value) : string
{
return mb_convert_case($value, MB_CASE_LOWER, 'UTF-8');
}

public static function countCharacters(string $value) : int
{
return strlen($value);
}
}

0 comments on commit 8536997

Please sign in to comment.