pickware / address-splitter

Tries to split street, number, building, apartment information etc. in a meaningful way
MIT License
98 stars 21 forks source link

move on instead of splittingException? #39

Open cloudswitch opened 10 months ago

cloudswitch commented 10 months ago

Hi,

awesome work guys, thank you! It's not really an issue however I have massive problems with this right now. We are testing the whole order process of the shop and someone has put xyz as street in the last order without house number. I'm getting of course splitting exception from line 290. The problem is I have no rights to delete this order from the shop and the whole download process is not working because of this. Would it be possible, that if the address is not splittable, simpy to just put street into streetName and create the array without houseNumber? I have tried it but had no luck. I would greatly appreciate any help. Thanks

larsbo commented 10 months ago

Why don't you handle the exception like you want? This is just a library and not a complete shop plugin. You can do something linke this

            try {
                $address = AddressSplitter::splitAddress($street);
            } catch (InvalidArgumentException $exception) {
                $address['streetName'] = $street;
                $address['houseNumber'] = '';
            }