alcohol / iso3166

A PHP library providing ISO 3166-1 data.
https://iso3166.thephpleague.com
MIT License
640 stars 59 forks source link

Enabling replacing the country list #14

Closed nyamsprod closed 8 years ago

nyamsprod commented 8 years ago
alcohol commented 8 years ago

This changes far more than necessary in my humble opinion. Those who want to provide an alternate data set, probably know what they are doing, and thus validation is really not required.

nyamsprod commented 8 years ago

Since you don't want a simple country value object at least you should validate the input data.

Adding the validation/normalization steps enables:

nyamsprod commented 8 years ago

I've move the validation out in another class. So If the developer wants to validate his data prior to instantiation he can do it with the new class. Then he simply injects the new list into ISO3166 constructor

<?php

use League\ISO3166\ISO3166;
use League\ISO3166\CountryValidator;

$input_data; //some country data in an array
$validator = new CountryValidator();
$collection = new ISO3166($validator->validateMany($input_data));

The use of the CountryValidator is not required but highly recommended if you are not sure about your input data.

alcohol commented 8 years ago

I can see the use-case for a validator, though I would rather call it DataValidator, not specifically CountryValidator. Let me tinker around a bit and come up with a counter proposal.

nyamsprod commented 8 years ago

The names can be changed this is only a proposal 👍

alcohol commented 8 years ago

Can you give me your thoughts on #18?

nyamsprod commented 8 years ago

18 adds the same features as this PR. So I'm closing it :+1: