Skip to content

Commit 8269aa1

Browse files
authored
guid fix (#140)
1 parent cdea9e5 commit 8269aa1

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/Guid.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SmartEmailing\Types;
66

7+
use Nette\Utils\Strings;
78
use SmartEmailing\Types\Comparable\ComparableInterface;
89
use SmartEmailing\Types\Comparable\StringComparableTrait;
910
use SmartEmailing\Types\ExtractableTraits\StringExtractableTrait;
@@ -15,12 +16,16 @@ final class Guid implements ToStringInterface, ComparableInterface
1516
use ToStringTrait;
1617
use StringComparableTrait;
1718

19+
private string $value;
20+
1821
private function __construct(
19-
private string $value
22+
string $value
2023
) {
2124
if (\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', $value) !== 1) {
2225
throw new InvalidTypeException('Invalid guid value');
2326
}
27+
28+
$this->value = Strings::lower($value);
2429
}
2530

2631
public static function fromHex32(

tests/GuidTest.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ declare(strict_types = 1);
44

55
namespace SmartEmailing\Types;
66

7+
use Nette\Utils\Strings;
78
use Tester\Assert;
89
use Tester\TestCase;
910

@@ -32,11 +33,16 @@ final class GuidTest extends TestCase
3233

3334
$validValues = [
3435
'd7c8539e-089e-11e8-b161-2edbc134be21',
36+
'd7c8539e-089E-11E8-B161-2edbc134be21',
3537
];
3638

3739
foreach ($validValues as $validValue) {
3840
$guid = Guid::from($validValue);
39-
Assert::equal($validValue, $guid->getValue());
41+
42+
Assert::equal(
43+
Strings::lower($validValue),
44+
$guid->getValue()
45+
);
4046
}
4147
}
4248

0 commit comments

Comments
 (0)