File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55namespace App \Core \Doctor \Domain ;
66
7+ use App \Shared \Uuid \Uuid ;
78use 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 }
Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff line change 44
55namespace App \Core \Visit \Domain ;
66
7+ use App \Shared \Uuid \Uuid ;
78use Doctrine \ORM \Mapping as ORM ;
89
910/**
1213class 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 }
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 66
77final class AddVisitTest extends E2ETestCase
88{
9- private int $ doctorId ;
9+ private string $ doctorId ;
1010 private int $ baseVisitCount ;
1111
1212 public function testHappyPath (): void
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments