<commit_before><?php

namespace CatLab\Charon\Enums;

use CatLab\Charon\Exceptions\InvalidContextAction;

/**
 * class Context
 * @package CatLab\RESTResource\Contracts
 */
class Action
{
    // Readable
    const INDEX = 'index';
    const VIEW = 'view';

    const IDENTIFIER = 'identifier';

    // Writable
    const CREATE = 'create';
    const EDIT = 'edit';

    /**
     * @param string $action
     * @return bool
     */
    public static function isReadContext($action)
    {
        return in_array($action, [ Action::INDEX, Action::VIEW, Action::IDENTIFIER ]);
    }

    /**
     * @param string $action
     * @return bool
     */
    public static function isWriteContext($action)
    {
        return in_array($action, [ Action::CREATE, Action::EDIT ]);
    }

    /**
     * @param string $action
     * @throws InvalidContextAction
     */
    public static function checkValid($action)
    {
        if (!self::isReadContext($action) && !self::isWriteContext($action)) {
            throw new InvalidContextAction("Unknown context provided: " . $action);
        }
    }
}<commit_msg>Don't allow expanding and viewing identifier context responses.<commit_after><?php

namespace CatLab\Charon\Enums;

use CatLab\Charon\Exceptions\InvalidContextAction;

/**
 * class Context
 * @package CatLab\RESTResource\Contracts
 */
class Action
{
    // Readable
    const INDEX = 'index';
    const VIEW = 'view';

    const IDENTIFIER = 'identifier';

    // Writable
    const CREATE = 'create';
    const EDIT = 'edit';

    /**
     * @param string $action
     * @return bool
     */
    public static function isReadContext($action)
    {
        return in_array($action, [ Action::INDEX, Action::VIEW, Action::IDENTIFIER ]);
    }

    /**
     * @param string $action
     * @return bool
     */
    public static function isWriteContext($action)
    {
        return in_array($action, [ Action::CREATE, Action::EDIT, Action::IDENTIFIER ]);
    }

    /**
     * @param string $action
     * @throws InvalidContextAction
     */
    public static function checkValid($action)
    {
        if (!self::isReadContext($action) && !self::isWriteContext($action)) {
            throw new InvalidContextAction("Unknown context provided: " . $action);
        }
    }
}
{'fraction_non_alphanumeric': 0.13037752414398596, 'fraction_numerical': 0.0, 'mean_word_length': 2.6405750798722045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6419449', 'n_tokens_mistral': 676, 'n_tokens_neox': 655, 'n_words': 154}