public function setDocument($doc)
    {
        $this->clearDocument();
        $doc = json_decode(json_encode($doc)); // ensure we are working with an object

        // set known properties
        if (!empty($doc->version)) {
            $this->version = $doc->version;
        }
        if (!empty($doc->href)) {
            $this->href = $doc->href;
        }
        if (!empty($doc->scope)) {
            $this->scope = $doc->scope;
        }
        if (!empty($doc->attributes)) {
            $this->attributes = $doc->attributes;
        }
        if (!empty($doc->links)) {
            $this->links = $doc->links;
        }
        if (!empty($doc->items)) {
            $this->items = $doc->items;
        }
        if (!empty($doc->errors)) {
            $this->errors = $doc->errors;
        }

        // get/set static links (preserving them between sets)
        foreach (self::$_staticLinkNames as $name) {
            if (empty($this->links->$name)) {
                $this->links->$name = self::$_staticLinks->$name;
            } else {
                self::$_staticLinks->$name = $this->links->$name;
            }
        }
        return $this;
    }
public function setDocument($doc)
    {
        $this->clearDocument();
        $doc = json_decode(json_encode($doc)); // ensure we are working with an object

        // set known properties
        if (!empty($doc->version)) {
            $this->version = $doc->version;
        }
        if (!empty($doc->href)) {
            $this->href = $doc->href;
        }
        if (!empty($doc->scope)) {
            $this->scope = $doc->scope;
        }
        if (!empty($doc->attributes)) {
            $this->attributes = $doc->attributes;
        }
        if (!empty($doc->links)) {
            $this->links = $doc->links;
        }
        if (!empty($doc->items)) {
            $this->items = $doc->items;
        }
        if (!empty($doc->errors)) {
            $this->errors = $doc->errors;
        }

        // get/set static links (preserving them between sets)
        foreach (self::$_staticLinkNames as $name) {
            if (empty($this->links->$name)) {
                $this->links->$name = self::$_staticLinks->$name;
            } else {
                self::$_staticLinks->$name = $this->links->$name;
            }
        }
        return $this;
    }
public function setDocument ( $ doc ) { $ this -> clearDocument ( ) ; $ doc = json_decode ( json_encode ( $ doc ) ) ; // ensure we are working with an object // set known properties if ( ! empty ( $ doc -> version ) ) { $ this -> version = $ doc -> version ; } if ( ! empty ( $ doc -> href ) ) { $ this -> href = $ doc -> href ; } if ( ! empty ( $ doc -> scope ) ) { $ this -> scope = $ doc -> scope ; } if ( ! empty ( $ doc -> attributes ) ) { $ this -> attributes = $ doc -> attributes ; } if ( ! empty ( $ doc -> links ) ) { $ this -> links = $ doc -> links ; } if ( ! empty ( $ doc -> items ) ) { $ this -> items = $ doc -> items ; } if ( ! empty ( $ doc -> errors ) ) { $ this -> errors = $ doc -> errors ; } // get/set static links (preserving them between sets) foreach ( self :: $ _staticLinkNames as $ name ) { if ( empty ( $ this -> links -> $ name ) ) { $ this -> links -> $ name = self :: $ _staticLinks -> $ name ; } else { self :: $ _staticLinks -> $ name = $ this -> links -> $ name ; } } return $ this ; }
Set this documents payload

@param \StdClass|array $doc the document object
@return self
Set this documents payload