src/CMDBCategory.php
public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
        $params = [
            'object' => $objectID,
            'data' => $attributes,
            'category' => $categoryConstant
        ];

        if (isset($entryID)) {
            $params['entry'] = $entryID;
        }

        $result = $this->api->request(
            'cmdb.category.save',
            $params
        );

        if (!array_key_exists('entry', $result) ||
            !is_int($result['entry']) ||
            !array_key_exists('success', $result) ||
            $result['success'] !== true) {
            if (array_key_exists('message', $result)) {
                throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
            } else {
                throw new RuntimeException('Bad result');
            }
        }

        return $result['entry'];
    }
public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
        $params = [
            'object' => $objectID,
            'data' => $attributes,
            'category' => $categoryConstant
        ];

        if (isset($entryID)) {
            $params['entry'] = $entryID;
        }

        $result = $this->api->request(
            'cmdb.category.save',
            $params
        );

        if (!array_key_exists('entry', $result) ||
            !is_int($result['entry']) ||
            !array_key_exists('success', $result) ||
            $result['success'] !== true) {
            if (array_key_exists('message', $result)) {
                throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
            } else {
                throw new RuntimeException('Bad result');
            }
        }

        return $result['entry'];
    }
public function save ( $ objectID , $ categoryConstant , array $ attributes , $ entryID = null ) { $ params = [ 'object' => $ objectID , 'data' => $ attributes , 'category' => $ categoryConstant ] ; if ( isset ( $ entryID ) ) { $ params [ 'entry' ] = $ entryID ; } $ result = $ this -> api -> request ( 'cmdb.category.save' , $ params ) ; if ( ! array_key_exists ( 'entry' , $ result ) || ! is_int ( $ result [ 'entry' ] ) || ! array_key_exists ( 'success' , $ result ) || $ result [ 'success' ] !== true ) { if ( array_key_exists ( 'message' , $ result ) ) { throw new RuntimeException ( sprintf ( 'Bad result: %s' , $ result [ 'message' ] ) ) ; } else { throw new RuntimeException ( 'Bad result' ) ; } } return $ result [ 'entry' ] ; }
Create new or update existing category entry for a specific object

Suitable for single- and multi-value categories

@param int $objectID Object identifier
@param string $categoryConstant Category constant
@param array $attributes Attributes as key-value pairs
@param int $entryID Entry identifier (only needed for multi-valued categories)

@return int Entry identifier

@throws Exception on error
Create new or update existing category entry for a specific object