<commit_before><?php

class VracSecurity implements SecurityInterface {

    const DECLARANT = 'DECLARANT';
    const CONSULTATION = 'CONSULTATION';
    const CREATION = 'CREATION';
    const SUPPRESSION = 'SUPPRESSION';
    const EDITION = 'EDITION';
    const SIGNATURE = 'SIGNATURE';
    const ENLEVEMENT = 'ENLEVEMENT';
    const CLOTURE = 'CLOTURE';

    protected $instance;
    protected $vrac;
    protected $myUser;

    public static function getInstance($myUser, $vrac = null) {

        return new VracSecurity($myUser, $vrac);
    }

    public function __construct($myUser, $vrac = null) {
        $this->myUser = $myUser;
        $this->vrac = $vrac;
        $this->tiers = $this->myUser->getDeclarant();
    }

    public function isAuthorized($droits) {
        if(!is_array($droits)) {
            $droits = array($droits);
        }

        /*** DECLARANT ***/

        if(!$this->tiers->isDeclarantContrat()) {
            
            return false;
        }

        if(!$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_VRAC_SIGNATURE) && !$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_VRAC_RESPONSABLE)) {
            
            return false;
        }

        if(in_array(self::DECLARANT, $droits)) {

            return true;
        }

        /*** CREATION ***/

        if(in_array(self::CREATION, $droits) && $this->tiers->isDeclarantContratForResponsable()) {

            return false;
        }

        if(in_array(self::CREATION, $droits)) {

            return true;
        }

        /*** EDITION ***/<commit_msg>Bug sur les droits de création dans les contrats<commit_after><?php

class VracSecurity implements SecurityInterface {

    const DECLARANT = 'DECLARANT';
    const CONSULTATION = 'CONSULTATION';
    const CREATION = 'CREATION';
    const SUPPRESSION = 'SUPPRESSION';
    const EDITION = 'EDITION';
    const SIGNATURE = 'SIGNATURE';
    const ENLEVEMENT = 'ENLEVEMENT';
    const CLOTURE = 'CLOTURE';

    protected $instance;
    protected $vrac;
    protected $myUser;

    public static function getInstance($myUser, $vrac = null) {

        return new VracSecurity($myUser, $vrac);
    }

    public function __construct($myUser, $vrac = null) {
        $this->myUser = $myUser;
        $this->vrac = $vrac;
        $this->tiers = $this->myUser->getDeclarant();
    }

    public function isAuthorized($droits) {
        if(!is_array($droits)) {
            $droits = array($droits);
        }

        /*** DECLARANT ***/

        if(!$this->tiers->isDeclarantContrat()) {
            
            return false;
        }

        if(!$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_VRAC_SIGNATURE) && !$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_VRAC_RESPONSABLE)) {
            
            return false;
        }

        if(in_array(self::DECLARANT, $droits)) {

            return true;
        }

        /*** CREATION ***/

        if(in_array(self::CREATION, $droits) && !$this->tiers->isDeclarantContratForResponsable()) {

            return false;
        }

        if(in_array(self::CREATION, $droits)) {

            return true;
        }

        /*** EDITION ***/
{'fraction_non_alphanumeric': 0.1396735718769617, 'fraction_numerical': 0.0, 'mean_word_length': 2.3094496365524404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '3866930', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1009, 'n_words': 178}