commerceguys / addressing

A PHP addressing library, powered by CLDR and Google's address data.
MIT License
922 stars 135 forks source link

Code examples #153

Closed vincentcox closed 3 years ago

vincentcox commented 3 years ago

Hi there,

Is it possible to provide an example for the HTML formatter?

Are there other code snippets available of this repo to see what this plugin can do?

Thanks in advance!

bojanz commented 3 years ago

Any chance you could take a look at the README?

vincentcox commented 3 years ago

I understand where your reaction comes from, I also maintain a repo where I get "strange" questions.

But let's view this piece of code from the readme:

$address = new Address();
$address = $address
    ->withCountryCode('US')
    ->withAdministrativeArea('CA')
    ->withLocality('Mountain View')
    ->withAddressLine1('1098 Alta Ave');

echo $formatter->format($address);

Does the format function has a parameter to use the html formatting?

That's not clear to me after reading the readme file.

bojanz commented 3 years ago

Further up we have this note:

$formatter = new DefaultFormatter($addressFormatRepository, $countryRepository, $subdivisionRepository);
// Options passed to the constructor or format() allow turning off
// html rendering, customizing the wrapper element and its attributes.

This indicates that there's more to look into. It is assumed that you will look into the code at some point, few libraries document every aspect, though I definitely welcome PRs with documentation improvements.

vincentcox commented 3 years ago

I looked into the code and it's indeed clear now. Sorry for RTFM'ing me. Closing the issue.