ContactPointType.php 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace AppBundle\Entity\Traits;
  3. use AppBundle\Enum\Core\ContactPointTypeEnum;
  4. /**
  5. * Description of ContactPointType
  6. *
  7. * @author Sébastien Hupin <sebastien.hupin at gmail.com>
  8. */
  9. trait ContactPointType
  10. {
  11. /**
  12. *
  13. * @param string $type
  14. * @return \AppBundle\Entity\Core\ContactPoint or null
  15. */
  16. public function getContactPointForType($type) {
  17. $contactPointEnum = new ContactPointTypeEnum($type);
  18. if ($this->getContactPoint()) {
  19. foreach($this->getContactPoint() as $contactPoint) {
  20. if ($contactPointEnum->getValue() === $contactPoint->getContactType()) {
  21. return $contactPoint;
  22. }
  23. }
  24. }
  25. return null;
  26. }
  27. /**
  28. *
  29. * @return \AppBundle\Entity\Core\ContactPoint or null
  30. */
  31. public function getContactPointPrincipal() {
  32. return $this->getContactPointForType(ContactPointTypeEnum::PRINCIPAL);
  33. }
  34. }
  35. ?>