Skip to content

Commit a76ddbd

Browse files
introduced uuid
1 parent 6c29360 commit a76ddbd

7 files changed

Lines changed: 32 additions & 19 deletions

File tree

src/Core/Doctor/Domain/Doctor.php

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

55
namespace App\Core\Doctor\Domain;
66

7+
use App\Shared\Uuid\Uuid;
78
use Doctrine\ORM\Mapping as ORM;
89

910
/**
@@ -13,10 +14,9 @@ final class Doctor
1314
{
1415
/**
1516
* @ORM\Id()
16-
* @ORM\GeneratedValue()
17-
* @ORM\Column(type="integer")
17+
* @ORM\Column(type="guid")
1818
*/
19-
private int $id;
19+
private string $id;
2020

2121
/**
2222
* @ORM\Column(type="string", length=255)
@@ -25,10 +25,11 @@ final class Doctor
2525

2626
public function __construct(string $name)
2727
{
28+
$this->id = (string) Uuid::uuid4();
2829
$this->name = $name;
2930
}
3031

31-
public function id(): int
32+
public function id(): string
3233
{
3334
return $this->id;
3435
}

src/Core/Visit/Application/AddVisit/AddVisitService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __invoke(AddVisitInput $input): void
2121
$visit = new Visit(
2222
$input->date(),
2323
$input->duration(),
24-
(int) $input->doctorId()
24+
$input->doctorId()
2525
);
2626

2727
$this->manager->persist($visit);

src/Core/Visit/Domain/Visit.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Core\Visit\Domain;
66

7+
use App\Shared\Uuid\Uuid;
78
use Doctrine\ORM\Mapping as ORM;
89

910
/**
@@ -12,11 +13,10 @@
1213
class Visit
1314
{
1415
/**
15-
* @ORM\Id
16-
* @ORM\GeneratedValue
17-
* @ORM\Column(type="integer")
16+
* @ORM\Id()
17+
* @ORM\Column(type="guid")
1818
*/
19-
private int $id;
19+
private string $id;
2020

2121
/**
2222
* @ORM\Column(type="datetime_immutable")
@@ -29,18 +29,19 @@ class Visit
2929
private int $duration;
3030

3131
/**
32-
* @ORM\Column(type="integer")
32+
* @ORM\Column(type="string")
3333
*/
34-
private int $doctor;
34+
private string $doctor;
3535

36-
public function __construct(\DateTimeImmutable $date, int $duration, int $doctorId)
36+
public function __construct(\DateTimeImmutable $date, int $duration, string $doctorId)
3737
{
38+
$this->id = (string) Uuid::uuid4();
3839
$this->date = $date;
3940
$this->duration = $duration;
4041
$this->doctor = $doctorId;
4142
}
4243

43-
public function id(): int
44+
public function id(): string
4445
{
4546
return $this->id;
4647
}
@@ -55,7 +56,7 @@ public function duration(): int
5556
return $this->duration;
5657
}
5758

58-
public function doctor(): int
59+
public function doctor(): string
5960
{
6061
return $this->doctor;
6162
}

src/DataFixtures/AppFixtures.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ public function load(ObjectManager $manager): void
2121
$entities[] = (new Visit(
2222
new \DateTimeImmutable('2021-10-10 16:20:00'),
2323
45,
24-
1
24+
$entities[0]->id()
2525
));
2626

2727
$entities[] = (new Visit(
2828
new \DateTimeImmutable('2021-10-11 08:00:00'),
2929
30,
30-
1
30+
$entities[0]->id()
3131
));
3232

3333
$entities[] = (new Visit(
3434
new \DateTimeImmutable('2021-10-15 10:30:00'),
3535
60,
36-
2
36+
$entities[1]->id()
3737
));
3838

3939
foreach ($entities as $entity) {

src/Shared/Uuid/Uuid.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Shared\Uuid;
6+
7+
use Ramsey\Uuid\Uuid as RamseyUuid;
8+
9+
final class Uuid extends RamseyUuid
10+
{
11+
}

tests/AddVisitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
final class AddVisitTest extends E2ETestCase
88
{
9-
private int $doctorId;
9+
private string $doctorId;
1010
private int $baseVisitCount;
1111

1212
public function testHappyPath(): void

tests/E2ETestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function lastResponseBody(): array
5050
return \json_decode($this->client->getResponse()->getContent(), true);
5151
}
5252

53-
protected function getFirstIdFromLastResponse(): int
53+
protected function getFirstIdFromLastResponse(): string
5454
{
5555
$body = $this->lastResponseBody();
5656

0 commit comments

Comments
 (0)