<commit_before><?php

class PagePermissions
{

    public function __construct($objects = array())
    {
        foreach ($objects as $object => $restriction) {
            $this->setEditRestriction($object, $restriction);
        }
    }

    private $only_admins_can_edit = false;

    private $only_group_can_edit = false;

    private $only_owner_can_edit = false;

    private $only_others_can_edit = false;

    public function getEditRestriction($object)
    {
        $varName = "only_{$object}_can_edit";
        if (! isset($this->$varName)) {
            return null;
        }
        return $this->$varName;
    }

    public function setEditRestriction($object, $restricted = false)
    {
        $varName = "only_{$object}_can_edit";
        if (! isset($this->$varName)) {
            return;
        }
        $this->$varName = boolval($restricted);
    }

    public function getAll()
    {
        $result = array();
        $classArray = (array) $this;
        foreach ($classArray as $key => $value) {
            preg_match("/only_([a-z]+)_can_edit/", $key, $matches);
            if (count($matches) >= 2) {
                $object = $matches[1];
                $result[$object] = $value;
            }
        }
        return $result;
    }
}<commit_msg>save Funktion hinzugefügt, noch nicht implementiert.<commit_after><?php

class PagePermissions
{

    public function __construct($objects = array())
    {
        foreach ($objects as $object => $restriction) {
            $this->setEditRestriction($object, $restriction);
        }
    }

    private $only_admins_can_edit = false;

    private $only_group_can_edit = false;

    private $only_owner_can_edit = false;

    private $only_others_can_edit = false;

    public function getEditRestriction($object)
    {
        $varName = "only_{$object}_can_edit";
        if (! isset($this->$varName)) {
            return null;
        }
        return $this->$varName;
    }

    public function setEditRestriction($object, $restricted = false)
    {
        $varName = "only_{$object}_can_edit";
        if (! isset($this->$varName)) {
            return;
        }
        $this->$varName = boolval($restricted);
    }

    public function getAll()
    {
        $result = array();
        $classArray = (array) $this;
        foreach ($classArray as $key => $value) {
            preg_match("/only_([a-z]+)_can_edit/", $key, $matches);
            if (count($matches) >= 2) {
                $object = $matches[1];
                $result[$object] = $value;
            }
        }
        return $result;
    }
    public function save($id){
        throw new NotImplementedException("save permissions not implemented yet.");
    }
}
{'fraction_non_alphanumeric': 0.1349264705882353, 'fraction_numerical': 0.0014705882352941176, 'mean_word_length': 2.13840830449827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '4621116', 'n_tokens_mistral': 837, 'n_tokens_neox': 802, 'n_words': 163}