Skip to content

Commit 8536997

Browse files
authored
Merge pull request #27 from Talentify/fix/add-zipcode-validation
change method setValue and remove countCharacters from StringUtils
2 parents cbcce5b + b799027 commit 8536997

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/Geography/Address/ByCountry/Us/ZipCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
*/
1313
class ZipCode extends PostalCode
1414
{
15-
public function setValue(string $value): void
15+
protected function setValue(string $value): void
1616
{
1717
$value = StringUtils::trimSpacesWisely($value);
1818
$changedValue = StringUtils::removeNonWordCharacters($value);
19-
$characters = StringUtils::countCharacters($changedValue);
19+
$characters = strlen($changedValue);
2020

2121
if ($characters == 4) {
2222
$value = '0' . $value;

src/Geography/Address/PostalCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(string $value)
2424
$this->setValue($value);
2525
}
2626

27-
public function setValue(string $value) : void
27+
protected function setValue(string $value) : void
2828
{
2929
$normalized = StringUtils::trimSpacesWisely($value);
3030
if (empty($normalized)) {

src/StringUtils.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,4 @@ public static function convertCaseToLower(string $value) : string
4949
{
5050
return mb_convert_case($value, MB_CASE_LOWER, 'UTF-8');
5151
}
52-
53-
public static function countCharacters(string $value) : int
54-
{
55-
return strlen($value);
56-
}
5752
}

0 commit comments

Comments
 (0)