@@ -222,11 +222,11 @@ entity definition:
222222 /**
223223 * @var int
224224 */
225- protected $id;
225+ private $id;
226226 /**
227227 * @var string
228228 */
229- protected $name;
229+ private $name;
230230 }
231231
232232 When creating entity classes, all of the fields should be ``private ``.
@@ -424,20 +424,20 @@ Then we can add a new mutator to our ``User``:
424424 <?php
425425 class User
426426 {
427- public function updateFromProfile(ProfileEditingForm $profileForm ): void
427+ public function updateFromProfile(ProfileEditingDTO $profileFormDTO ): void
428428 {
429429 // ...
430430 }
431431
432- public static function createFromRegistration(UserRegistrationForm $registrationForm ): self
432+ public static function createFromRegistration(UserRegistrationDTO $registrationDTO ): self
433433 {
434434 // ...
435435 }
436436 }
437437
438438 There are several advantages to using such a model:
439439
440- * **Entity state is always valid **. Since no setters exist, this means that we
440+ * **Entity state is always valid. ** Since no setters exist, this means that we
441441only update portions of the entity that should already be valid.
442442* Instead of having plain getters and setters, our entity now has
443443**real behavior **: it is much easier to determine the logic in the domain.
@@ -474,10 +474,10 @@ but you only need to choose one.
474474 class Product
475475 {
476476 /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue **/
477- protected $id;
477+ private $id;
478478
479479 /** @ORM\Column(type="string") **/
480- protected $name;
480+ private $name;
481481
482482 // .. (other code)
483483 }
@@ -647,25 +647,25 @@ classes. We'll store them in ``src/Bug.php`` and ``src/User.php``, respectively.
647647 * @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue
648648 * @var int
649649 */
650- protected $id;
650+ private $id;
651651
652652 /**
653653 * @ORM\Column(type="string")
654654 * @var string
655655 */
656- protected $description;
656+ private $description;
657657
658658 /**
659659 * @ORM\Column(type="datetime")
660660 * @var DateTime
661661 */
662- protected $created;
662+ private $created;
663663
664664 /**
665665 * @ORM\Column(type="string")
666666 * @var string
667667 */
668- protected $status;
668+ private $status;
669669
670670 public function getId()
671671 {
@@ -720,13 +720,13 @@ classes. We'll store them in ``src/Bug.php`` and ``src/User.php``, respectively.
720720 * @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer")
721721 * @var int
722722 */
723- protected $id;
723+ private $id;
724724
725725 /**
726726 * @ORM\Column(type="string")
727727 * @var string
728728 */
729- protected $name;
729+ private $name;
730730
731731 public function getId()
732732 {
@@ -773,7 +773,7 @@ domain model to match the requirements:
773773 {
774774 // ... (previous code)
775775
776- protected $products;
776+ private $products;
777777
778778 public function __construct()
779779 {
@@ -791,8 +791,8 @@ domain model to match the requirements:
791791 {
792792 // ... (previous code)
793793
794- protected $reportedBugs;
795- protected $assignedBugs;
794+ private $reportedBugs;
795+ private $assignedBugs;
796796
797797 public function __construct()
798798 {
@@ -866,8 +866,8 @@ the bi-directional reference:
866866 {
867867 // ... (previous code)
868868
869- protected $engineer;
870- protected $reporter;
869+ private $engineer;
870+ private $reporter;
871871
872872 public function setEngineer(User $engineer)
873873 {
@@ -900,8 +900,8 @@ the bi-directional reference:
900900 {
901901 // ... (previous code)
902902
903- protected $reportedBugs;
904- protected $assignedBugs;
903+ private $reportedBugs;
904+ private $assignedBugs;
905905
906906 public function addReportedBug(Bug $bug)
907907 {
@@ -952,7 +952,7 @@ the database that points from Bugs to Products.
952952 {
953953 // ... (previous code)
954954
955- protected $products = null;
955+ private $products = null;
956956
957957 public function assignToProduct(Product $product)
958958 {
@@ -987,37 +987,37 @@ the ``Product`` before:
987987 /**
988988 * @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue
989989 **/
990- protected $id;
990+ private $id;
991991
992992 /**
993993 * @ORM\Column(type="string")
994994 **/
995- protected $description;
995+ private $description;
996996
997997 /**
998998 * @ORM\Column(type="datetime")
999999 **/
1000- protected $created;
1000+ private $created;
10011001
10021002 /**
10031003 * @ORM\Column(type="string")
10041004 **/
1005- protected $status;
1005+ private $status;
10061006
10071007 /**
10081008 * @ORM\ManyToOne(targetEntity="User", inversedBy="assignedBugs")
10091009 **/
1010- protected $engineer;
1010+ private $engineer;
10111011
10121012 /**
10131013 * @ORM\ManyToOne(targetEntity="User", inversedBy="reportedBugs")
10141014 **/
1015- protected $reporter;
1015+ private $reporter;
10161016
10171017 /**
10181018 * @ORM\ManyToMany(targetEntity="Product")
10191019 **/
1020- protected $products;
1020+ private $products;
10211021
10221022 // ... (other code)
10231023 }
@@ -1089,25 +1089,25 @@ Finally, we'll add metadata mappings for the ``User`` entity.
10891089 * @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer")
10901090 * @var int
10911091 **/
1092- protected $id;
1092+ private $id;
10931093
10941094 /**
10951095 * @ORM\Column(type="string")
10961096 * @var string
10971097 **/
1098- protected $name;
1098+ private $name;
10991099
11001100 /**
11011101 * @ORM\OneToMany(targetEntity="Bug", mappedBy="reporter")
11021102 * @var Bug[] An ArrayCollection of Bug objects.
11031103 **/
1104- protected $reportedBugs = null;
1104+ private $reportedBugs = null;
11051105
11061106 /**
11071107 * @ORM\OneToMany(targetEntity="Bug", mappedBy="engineer")
11081108 * @var Bug[] An ArrayCollection of Bug objects.
11091109 **/
1110- protected $assignedBugs = null;
1110+ private $assignedBugs = null;
11111111
11121112 // .. (other code)
11131113 }
0 commit comments