-
-
Save ramiror/69264236c54288d27edfa57335c54ad6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| final class SocialNetworkProfile { | |
| private $userName; | |
| private $friends; // friends is a reference to a large collection | |
| private $feed; // feed references the whole user feed | |
| public __construct($userName , $friends, UserFeed $feed) { | |
| $this->assertUsernameIsValid($userName); | |
| $this->assertNoFriendDuplicates($friends); | |
| $this->userName = $userName; | |
| $this->friends = $friends; | |
| $this->feed = $feed | |
| $this->assertNoFriendofMylsef($friends); | |
| } | |
| // Lots of protocol | |
| } | |
| // If we need to transfer to an External system we need | |
| // to duplicate (and maintain) the structure | |
| final class SocialNetworkProfileDTO { | |
| private $userName; | |
| public __construct() { | |
| // Empty construct without validations | |
| } | |
| // No protocol, just serializers | |
| // If we need to transfer to an External system we create an anemic DTO | |
| $janesProfileToTransfer = new SocialNetworkProfileDTO('jane'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment