DivideBV / Postnl

Library to connect to PostNL's SOAP service called CIF
GNU General Public License v2.0
31 stars 40 forks source link

How to get the string of an openingshour #53

Closed matthijs-neijenhuijs closed 5 years ago

matthijs-neijenhuijs commented 7 years ago

When i do:

$location->getName() on the ResponseLocation class it works. I get a string in return.

But when i do:

$location->getOpeningHours()->getMonday()

I get:

stdClass Object ( [string] => 08:00-18:30 ) 1

Sorry for the newbie question, but how do i get just the string in return?

I dont understand why it is not a string:

    /**
     * @return string
     */
    public function getMonday()
    {
        return $this->Monday;
    }
ameenross commented 7 years ago

(sorry for the noise, posted a reply here to another issue)

It seems to be due to the serialization PostNL uses. https://developer.postnl.nl/apis/location-webservice/documentation

It seems to support it being an array (probably to allow for, let's say, 8:00-12:00, 12:30-16:30). You can do $location->getOpeningHours()->getMonday()->string, but it's not very developer friendly, and there's a discrepancy between the documentation and the code. I'm not sure how to improve this, as the result could be an array. If anyone knows whether this happens in practice, please share the knowledge