jeremykendall / php-domain-parser

Public Suffix List based domain parsing implemented in PHP
MIT License
1.16k stars 128 forks source link

ability to get all domain labels #238

Closed Insolita closed 5 years ago

Insolita commented 5 years ago

Domain has methods for get Label by key, and for get key by label, but we can't get whole array with labels, and when we need it - we are forced to make additional manipulations

nyamsprod commented 5 years ago

So instead of

<?php

$labels = iterator_to_array($domain, false);

you would like

<?php

$labels = $domain->labels();

am I correct ?

Insolita commented 5 years ago

yes - is more clear

nyamsprod commented 5 years ago

I'll create the PR for that this evening it's easy to add I don't recall why this one was not added 🤔 . But I was not convince to add it back then. And also for resolving it is not really needed ... only iteration is needed maybe that's the reason 😄

nyamsprod commented 5 years ago

but just like the new method this one won't be present in the interface after addition

nyamsprod commented 5 years ago

when we need it - we are forced to make additional manipulations

Now I remember why this one was not added. The fact that DomainInterface

rendered having this method not so much needed. Do you have a simple scenario where the current API fell short 🤔 . For which the array representation would be superior ?

The current public API covers most of its use case. I'd say maybe adding a Domain::createfromIterable would do but apart from that I have to wonder ?

I have no issue adding this method but these where the reason why the method was not added I believe at some point during the v5 development the method was present but was subsequently removed to avoid duplication.