Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Acme;
  4.  
  5. class DataTransfer
  6. {
  7. public static function forUser(
  8. $user_id
  9. ) {
  10. return new static($user_id);
  11. }
  12.  
  13. public static function forCompany(
  14. $company_id
  15. ) {
  16. return new static(null, $company_id);
  17. }
  18.  
  19. private $user_id;
  20. private $company_id;
  21.  
  22. public function userId()
  23. {
  24. return $this->user_id;
  25. }
  26.  
  27. public function companyId()
  28. {
  29. return $this->company_id;
  30. }
  31.  
  32. private function __construct(
  33. $user_id = null,
  34. $company_id = null
  35. ) {
  36. if ($user_id) {
  37. $this->user_id = $user_id;
  38. }
  39.  
  40. if ($company_id) {
  41. $this->company_id = $company_id;
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement