選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

62 行
1.7KB

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