<commit_before><?php

/**
 * Copyright (C) 2016-17 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * @author <NAME> <https://benjamin.heisig.name/>
 * @copyright Copyright (C) 2016-17 <NAME>
 * @license http://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License (AGPL)
 * @link https://github.com/bheisig/i-doit-api-client-php
 */

namespace bheisig\idoitapi;

/**
 * Requests for API namespace 'cmdb.category_info'
 */
class CMDBCategoryInfo extends Request {

    /**
     * Fetches information about a category
     *
     * @param string $categoryConst Category constant
     *
     * @return array Result set
     *
     * @throws \Exception on error
     */
    public function read($categoryConst) {

        return $this->api->request(
            'cmdb.category_info',
            array(
                'category' => $categoryConst
            )
        );
    }

    /**
     * Fetches information about one or more categories
     *
     * This only works with "global" categories.
     *
     * @param array $categories List of category constants as keys and whether they are global (boolean) as values
     *
     * @return array Indexed array of associative arrays
     *
     * @throws \Exception on error
     */
    public function batchRead(array $categories) {
        $requests = [];

        foreach ($categories as $const => $isGlobal) {
            $params = [];

            if ($isGlobal) {
                $params['catgID'] = $const;
            } else {
                $params['catsID'] = $const;
            }

            $requests[] = [
                'method' => 'cmdb.category_info',
                'params' => $params
            ];
        }
    }

    /**
     * Fetches information about one or more categories
     * @param array $categories
     * @throws \Exception on error
     * @return array Indexed array of associative arrays
     */
    public function batchReadByConst(array $categories) {
        $requests = [];

        foreach ($categories as $category) {
<commit_msg>Fixed RegressionBug from Previous Commit.<commit_after><?php

/**
 * Copyright (C) 2016-17 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * @author <NAME> <https://benjamin.heisig.name/>
 * @copyright Copyright (C) 2016-17 <NAME>
 * @license http://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License (AGPL)
 * @link https://github.com/bheisig/i-doit-api-client-php
 */

namespace bheisig\idoitapi;

/**
 * Requests for API namespace 'cmdb.category_info'
 */
class CMDBCategoryInfo extends Request {

    /**
     * Fetches information about a category
     *
     * @param string $categoryConst Category constant
     *
     * @return array Result set
     *
     * @throws \Exception on error
     */
    public function read($categoryConst) {

        return $this->api->request(
            'cmdb.category_info',
            array(
                'category' => $categoryConst
            )
        );
    }

    /**
     * Fetches information about one or more categories
     *
     * This only works with "global" categories.
     *
     * @param array $categories List of category constants as keys and whether they are global (boolean) as values
     *
     * @return array Indexed array of associative arrays
     *
     * @throws \Exception on error
     */
    public function batchRead(array $categories) {
        $requests = [];

        foreach ($categories as $const => $isGlobal) {
            $params = [];

            if ($isGlobal) {
                $params['catgID'] = $const;
            } else {
                $params['catsID'] = $const;
            }

            $requests[] = [
                'method' => 'cmdb.category_info',
                'params' => $params
            ];
        }

        return $this->api->batchRequest($requests);
    }

    /**
     * Fetches information about one or more categories
     * @param array $categories
     * @throws \Exception on error
     * @return array Indexed array of associative arrays
     */
    public function batchReadByConst(array $categories) {
        $requests = [];

        foreach ($categories as $category) {

{'fraction_non_alphanumeric': 0.10123776094587104, 'fraction_numerical': 0.005542213190467393, 'mean_word_length': 2.275257108287961, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5362169', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1419, 'n_words': 520}