<commit_before><?php

//! @file ReplicableDoc.php
//! @brief This file contains the ReplicableDoc class.
//! @details
//! @author <NAME>


namespace ElephantOnCouch\Docs;


use ElephantOnCouch\Attachment;


//! @brief Standard documents and Design documents are both replicable documents.
//! @nosubgrouping
abstract class ReplicableDoc extends AbstractDoc {

  //! @name Replicable Document Properties
  //@{
  const ATTACHMENTS = "_attachments"; //!< The document attachments.
  const REVS_INFO = "_revs_info";
  const LOCAL_SEQUENCE = "_local_sequence"; //!< TODO
  const CONFLICTS = "_conflicts";
  const DELETED_CONFLICTS = "_deleted_conflicts";
  //@}

  //! If the document has attachments, holds a meta-data structure.
  private $attachments = []; // array of attachments

  //! A list of revisions of the document, and their availability.
  private $revsInfo = [];

  private $conflicts = [];

  private $deletedConflicts = [];


  public function getAttachments() {
    return $this->meta[self::ATTACHMENTS];
  }


  public function addAttachment(Attachment $attachment) {
    print "\n\nPASSO DI QUI!\n\n";

    $this->meta[self::ATTACHMENTS][$attachment->getName()] = $attachment->asArray();
  }


  public function removeAttachment($name) {
  }

}

?><commit_msg>modified getAttachments, removeAttachment and added getLocalSequence and setLocalSequence<commit_after><?php

//! @file ReplicableDoc.php
//! @brief This file contains the ReplicableDoc class.
//! @details
//! @author <NAME>


namespace ElephantOnCouch\Docs;


use ElephantOnCouch\Attachment;


//! @brief Standard documents and Design documents are both replicable documents.
//! @nosubgrouping
abstract class ReplicableDoc extends AbstractDoc {

  //! @name Replicable Document Properties
  //@{
  const ATTACHMENTS = "_attachments"; //!< The document attachments.
  const REVS_INFO = "_revs_info";
  const LOCAL_SEQUENCE = "_local_sequence"; //!< TODO
  const CONFLICTS = "_conflicts";
  const DELETED_CONFLICTS = "_deleted_conflicts";
  //@}

  //! If the document has attachments, holds a meta-data structure.
  private $attachments = []; // array of attachments

  //! A list of revisions of the document, and their availability.
  private $revsInfo = [];

  private $conflicts = [];

  private $deletedConflicts = [];


  public function getAttachments() {
    $attachments = [];

    foreach ($this->meta[self::ATTACHMENTS] as $attachment)
      $attachments[] = Attachment::fromArray($attachment);

    return $attachments;
  }


  public function addAttachment(Attachment $attachment) {
    $this->meta[self::ATTACHMENTS][$attachment->getName()] = $attachment->asArray();
  }


  public function removeAttachment($name) {
    if ($this->isMetadataPresent(self::ATTACHMENTS))
      if (array_key_exists($name, $this->meta[self::ATTACHMENTS]))
        unset($this->meta[self::ATTACHMENTS][$name]);
      else
        throw new \Exception("Can't find '$name' attachment in the document.");
    else
      throw new \Exception("The document doesn't have any attachment.");
  }


  public function getLocalSequence() {
    return $this->meta[self::LOCAL_SEQUENCE];
  }


  public function issetLocalSequence() {
    return $this->isMetadataPresent(self::LOCAL_SEQUENCE);
  }

}

?>
{'fraction_non_alphanumeric': 0.12998160637645617, 'fraction_numerical': 0.0, 'mean_word_length': 4.043276661514684, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '241056', 'n_tokens_mistral': 1002, 'n_tokens_neox': 944, 'n_words': 253}