Alaouy\Youtube\Youtube::decodeMultiple PHP Method

decodeMultiple() public method

Decode the response from youtube, extract the multiple resource object.
public decodeMultiple ( string &$apiData ) : StdClass
$apiData string the api response from youtube
return StdClass an Youtube resource object
    public function decodeMultiple(&$apiData)
    {
        $resObj = json_decode($apiData);
        if (isset($resObj->error)) {
            $msg = "Error " . $resObj->error->code . " " . $resObj->error->message;
            if (isset($resObj->error->errors[0])) {
                $msg .= " : " . $resObj->error->errors[0]->reason;
            }
            throw new \Exception($msg);
        } else {
            $itemsArray = $resObj->items;
            if (!is_array($itemsArray)) {
                return false;
            } else {
                return $itemsArray;
            }
        }
    }