You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Address;
  3. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  4. use Lc\CaracoleBundle\Model\Address\AddressModel;
  5. class AddressSolver
  6. {
  7. // getAddressSummary
  8. public function getSummaryShort(AddressInterface $address): string
  9. {
  10. return $address->getAddress() . ' - ' . $address->getZip() . ' ' . $address->getCity();
  11. }
  12. public function getSummary(AddressInterface $address, $withTitle = true): string
  13. {
  14. $html = '';
  15. if ($address->getTitle() && $withTitle) {
  16. $html .= $address->getTitle() . '<br />';
  17. }
  18. if ($address->getLastname() || $address->getFirstname()) {
  19. $html .= $address->getLastname() . ' ' . $address->getFirstname() . '<br />';
  20. }
  21. if ($address->getAddress()) {
  22. $html .= $address->getAddress() . '<br />';
  23. }
  24. if ($address->getZip() || $address->getCity()) {
  25. $html .= $address->getZip() . ' ' . $address->getCity() . '<br />';
  26. }
  27. if ($address->getPhone()) {
  28. foreach ($address->getPhone() as $phone) {
  29. $html .= 'Tél. ' . $phone . '<br />';
  30. }
  31. }
  32. return $html;
  33. }
  34. public function getLongitudeInherit(AddressInterface $address): ?string
  35. {
  36. if ($address->getLongitudeOverride()) {
  37. return $address->getLongitudeOverride();
  38. } else {
  39. return $address->getLongitude();
  40. }
  41. }
  42. public function getLatitudeInherit(AddressInterface $address): ?string
  43. {
  44. if ($address->getLatitudeOverride()) {
  45. return $address->getLatitudeOverride();
  46. } else {
  47. return $address->getLatitude();
  48. }
  49. }
  50. public static function getTypeChoices():array{
  51. return[
  52. AddressModel::TYPE_INDIVIDUAL,
  53. AddressModel::TYPE_LEGAL_PERSON,
  54. ];
  55. }
  56. }