<commit_before><?php

namespace PHPOrchestra\ModelBundle\Document;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use PHPOrchestra\ModelBundle\Mapping\Annotations as ORCHESTRA;
use PHPOrchestra\ModelBundle\Model\ContentAttributeInterface;
use PHPOrchestra\ModelBundle\Model\ContentInterface;
use PHPOrchestra\ModelBundle\Model\StatusInterface;
use PHPOrchestra\ModelBundle\Model\KeywordInterface;

/**
 * Description of Content
 *
 * @MongoDB\Document(
 *   collection="content",
 *   repositoryClass="PHPOrchestra\ModelBundle\Repository\ContentRepository"
 * )
 * @ORCHESTRA\Document(
 *   generatedField="contentId",
 *   sourceField="name",
 *   serviceName="php_orchestra_model.repository.content",
 * )
 */
class Content implements ContentInterface
{
    /**
     * @var string $id
     *
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @var int $contentId
     *
     * @MongoDB\Field(type="string")
     */
    protected $contentId;

    /**
     * @var string $contentType
     *
     * @MongoDB\Field(type="string")
     */
    protected $contentType;

    /**
     * @var string $siteId
     *
     * @MongoDB\Field(type="string")
     */
    protected $siteId;

    /**
     * @var string $name
     *
     * @MongoDB\Field(type="string")
     */
    protected $name;

    /**
     * @var int $version
     *
     * @MongoDB\Field(type="int")
     */
    protected $version;

    /**
     * @var int $contentTypeVersion
     *
     * @MongoDB\Field(type="int")
     */
    protected $contentTypeVersion;

    /**
     * @var string $language
     *
     * @MongoDB\Field(type="string")
     */
    protected $language;

    /**
     * @var StatusInterface $status
     *
     * @MongoDB\EmbedOne(targetDocument="EmbedStatus")
     */
    protected $status;

    /**
     * @var ArrayCollection
     *
     * @MongoDB\EmbedMany(targetDocument="EmbedKeyword")
     */
    protected $keywords;

    /**
     * @var boolean
     *
     * @MongoDB\Field(type="boolean")
     */
    protected $deleted = false;

    /**
     * @var ArrayCollection
     *
     * @MongoDB\EmbedMany(targetDocument="ContentAttribute")
     */
    protected $attributes;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->attributes = new ArrayCollection();
        $this->keywords = new ArrayCollection();
    }

    /**
     * @return ArrayCollection
     */
    public function getAttributes()
    {
        return $this->attributes;
    }

    /**
     * @param string $name
     *
     * @return ContentAttributeInterface|null
     */
    public function getAttributeByName($name)
    {
        foreach ($this->attributes as $attribute) {
            if ($name == $attribute->getName()) {
                return $attribute;
            }
        }

        return null;
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function addAttribute(ContentAttributeInterface $attribute)
    {
        $this->attributes->add($attribute);
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function removeAttribute(ContentAttributeInterface $attribute)
    {
        $this->attributes->removeElement($attribute);
    }

    /**
     * @return ArrayCollection
     */
    public function getKeywords()
    {
        return $this->keywords;
    }

    /**
     * @param string $label
     *
     * @return KeywordInterface|null
     */
    public function getKeywordByLabel($label)
    {
        foreach ($this->keywords as $keyword) {
            if ($label == $keyword->getLabel()) {
                return $keyword;
            }
        }

        return null;
    }

    /**
     * @param KeywordInterface $keyword
     */
    public function addKeyword(KeywordInterface $keyword)
    {
        $this->keywords->add(EmbedKeyword::createFromKeyword($keyword));
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function removeKeyword(KeywordInterface $keyword)
    {
        $this->keywords->removeElement($keyword);<commit_msg>Move creation into transformer<commit_after><?php

namespace PHPOrchestra\ModelBundle\Document;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use PHPOrchestra\ModelBundle\Mapping\Annotations as ORCHESTRA;
use PHPOrchestra\ModelBundle\Model\ContentAttributeInterface;
use PHPOrchestra\ModelBundle\Model\ContentInterface;
use PHPOrchestra\ModelBundle\Model\StatusInterface;
use PHPOrchestra\ModelBundle\Model\KeywordInterface;

/**
 * Description of Content
 *
 * @MongoDB\Document(
 *   collection="content",
 *   repositoryClass="PHPOrchestra\ModelBundle\Repository\ContentRepository"
 * )
 * @ORCHESTRA\Document(
 *   generatedField="contentId",
 *   sourceField="name",
 *   serviceName="php_orchestra_model.repository.content",
 * )
 */
class Content implements ContentInterface
{
    /**
     * @var string $id
     *
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @var int $contentId
     *
     * @MongoDB\Field(type="string")
     */
    protected $contentId;

    /**
     * @var string $contentType
     *
     * @MongoDB\Field(type="string")
     */
    protected $contentType;

    /**
     * @var string $siteId
     *
     * @MongoDB\Field(type="string")
     */
    protected $siteId;

    /**
     * @var string $name
     *
     * @MongoDB\Field(type="string")
     */
    protected $name;

    /**
     * @var int $version
     *
     * @MongoDB\Field(type="int")
     */
    protected $version;

    /**
     * @var int $contentTypeVersion
     *
     * @MongoDB\Field(type="int")
     */
    protected $contentTypeVersion;

    /**
     * @var string $language
     *
     * @MongoDB\Field(type="string")
     */
    protected $language;

    /**
     * @var StatusInterface $status
     *
     * @MongoDB\EmbedOne(targetDocument="EmbedStatus")
     */
    protected $status;

    /**
     * @var ArrayCollection
     *
     * @MongoDB\EmbedMany(targetDocument="EmbedKeyword")
     */
    protected $keywords;

    /**
     * @var boolean
     *
     * @MongoDB\Field(type="boolean")
     */
    protected $deleted = false;

    /**
     * @var ArrayCollection
     *
     * @MongoDB\EmbedMany(targetDocument="ContentAttribute")
     */
    protected $attributes;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->attributes = new ArrayCollection();
        $this->keywords = new ArrayCollection();
    }

    /**
     * @return ArrayCollection
     */
    public function getAttributes()
    {
        return $this->attributes;
    }

    /**
     * @param string $name
     *
     * @return ContentAttributeInterface|null
     */
    public function getAttributeByName($name)
    {
        foreach ($this->attributes as $attribute) {
            if ($name == $attribute->getName()) {
                return $attribute;
            }
        }

        return null;
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function addAttribute(ContentAttributeInterface $attribute)
    {
        $this->attributes->add($attribute);
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function removeAttribute(ContentAttributeInterface $attribute)
    {
        $this->attributes->removeElement($attribute);
    }

    /**
     * @return ArrayCollection
     */
    public function getKeywords()
    {
        return $this->keywords;
    }

    /**
     * @param string $label
     *
     * @return KeywordInterface|null
     */
    public function getKeywordByLabel($label)
    {
        foreach ($this->keywords as $keyword) {
            if ($label == $keyword->getLabel()) {
                return $keyword;
            }
        }

        return null;
    }

    /**
     * @param KeywordInterface $keyword
     */
    public function addKeyword(KeywordInterface $keyword)
    {
        $this->keywords->add($keyword);
    }

    /**
     * @param ContentAttributeInterface $attribute
     */
    public function removeKeyword(KeywordInterface $keyword)
    {
        $this->keywords->removeElement($keyword);
{'fraction_non_alphanumeric': 0.12860956078621694, 'fraction_numerical': 0.0, 'mean_word_length': 2.258102766798419, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '6178843', 'n_tokens_mistral': 2403, 'n_tokens_neox': 2358, 'n_words': 400}