function updateTarget($id, $target) {
        if(is_array($target)) {
            $target = new Target($target);
        }
        else if(!($target instanceof Target)) {
            throw new Exception("Invalid target type. Only array and VuforiaWebService/Target are supported");            
        }

        if(!empty($target->name)) {
            if(!empty($this->namingRule) && !preg_match($this->namingRule, $target->name)) {
                throw new Exception("Invalid naming"); 
            }
        }

        if(is_numeric($target->width)) {
            if($target->width <= 0) {
                throw new Exception("Target width should be a number");  
            }
        }

        if(!empty($target->image) && is_numeric($this->maxImageSize) && strlen($target->image) > $this->maxImageSize) {
            throw new Exception("Image is too large"); 
        }

        if(!empty($target->metadata) && is_numeric($this->maxMetaSize) && strlen($target->metadata) > $this->maxMetaSize) {
            throw new Exception("Metadata is too large"); 
        }

        return $this->makeRequest(
            $this->targets . "/$id",
            HTTP_Request2::METHOD_PUT,
            json_encode($target),
            ['Content-Type' => 'application/json']);
    }