kijin/pinboard-api

How do you tell when there are no results?

Closed this issue · 5 comments

Can you please set the return to null or something so I know when there are no results?

Which method(s) are you talking about?

get(), get_all(), and all the search methods return an array of PinboardBookmark objects, so if there are no results, they will naturally return an empty array. list_notes() will also return an empty array if you have no notes. get_note() is the only exception: it returns false when the note you're looking for doesn't exist.

Hmmm, I wasn't seeing an empty array. Let me check again and get back to you.

Ya the XML that comes back looks like this:

(
    (null)  =>  (
        @attributes =>  (
        )
    )

So I'm not sure you're handling that. Perhaps I'm missing something but it doesn't look quite right. I'm doing a get_all

Is that what you see when you print_r() the variable $xml from line 117, or is that what the get_all() method actually returns? Or are you just concerned about the abstract possibility that this library might not handle such cases gracefully?

Even if $xml contained something wacky like the above, it would be safely converted to an empty array before being returned. get_all() returns whatever $this->_xml_to_bookmark($xml) returns, and the latter defaults to an empty array if $xml does not contain any valid <post> tags. Are you sure you're not seeing the result of some debugging code that you added yourself?

In my testing, get_all() seems to be working fine. I always get an array, and the array is either empty or filled with a bunch of bookmarks.

It's what I see in the debugger (MacsGDBp) for $xml.

I trust that you know better than me. Great library, thanks for it!

Please close this then.