<commit_before><?php

class ArchivageDocument implements iLock
{
    protected $document;
    protected $format;

    public function __construct(acCouchdbDocument $document, $format = "%05d")
    {
        $this->document = $document;
        $this->format = $format;
    }

    public function reset() {
        $this->document->numero_archive = null;
    }
    
    public function preSave() {
        if ($this->document->isArchivageCanBeSet()) {
            $this->archiver();
        }
    }

    public function archiver() {
        if ($this->document->numero_archive) {
            return;
        }
	   Lock::runLock($this, $this->document->toJson()->type);
    }

    public function getCampagne() {
        if(method_exists($this->document, 'getCampagneArchive')) {

            return $this->document->getCampagneArchive();
        }

        $this->document->campagne;
    }

    public function executeLock($type = null) {
        $last_numero = ArchivageAllView::getInstance()->getLastNumeroArchiveByTypeAndCampagne($type, $this->getCampagne());
        $this->document->numero_archive = sprintf($this->format, $last_numero+1);
        
        return array('value' => $this->getCampagne().' '.$this->document->numero_archive, 'key' => $type, 'docid' => $this->document->_id);
    }
}
<commit_msg>Récupère correctement la campagne<commit_after><?php

class ArchivageDocument implements iLock
{
    protected $document;
    protected $format;

    public function __construct(acCouchdbDocument $document, $format = "%05d")
    {
        $this->document = $document;
        $this->format = $format;
    }

    public function reset() {
        $this->document->numero_archive = null;
    }
    
    public function preSave() {
        if ($this->document->isArchivageCanBeSet()) {
            $this->archiver();
        }
    }

    public function archiver() {
        if ($this->document->numero_archive) {
            return;
        }
	   Lock::runLock($this, $this->document->toJson()->type);
    }

    public function getCampagne() {
        if(method_exists($this->document, 'getCampagneArchive')) {

            return $this->document->getCampagneArchive();
        }

        return $this->document->campagne;
    }

    public function executeLock($type = null) {
        $last_numero = ArchivageAllView::getInstance()->getLastNumeroArchiveByTypeAndCampagne($type, $this->getCampagne());
        $this->document->numero_archive = sprintf($this->format, $last_numero+1);
        
        return array('value' => $this->getCampagne().' '.$this->document->numero_archive, 'key' => $type, 'docid' => $this->document->_id);
    }
}

{'fraction_non_alphanumeric': 0.1522804372408594, 'fraction_numerical': 0.0022615906520919715, 'mean_word_length': 2.77524893314367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '119949', 'n_tokens_mistral': 798, 'n_tokens_neox': 777, 'n_words': 132}