<commit_before><?php

namespace Klaviyo\Model;

/**
 * Simple model that represents a template.
 *
 * @property string $id
 * @property string $name
 * @property \DOMDocument $html
 * @property \DateTimeInterface $created
 * @property \DateTimeInterface $updated
 */
class TemplateModel extends BaseModel implements TemplateIdInterface
{
    protected $id;
    protected $name;
    protected $html;
    protected $created;
    protected $updated;
    protected static $optionalDefaults = [
        'name' => '',
        'created' => null,
        'updated' => null,
    ];
    protected static $mutableAttributes = [
        'html',
    ];

    /**
     * {@inheritdoc}
     */
    public function __construct($configuration)
    {
        parent::__construct($configuration);
        $configuration += self::$optionalDefaults;

        $this->id = $configuration['id'];
        $this->name = $configuration['name'];
        $this->created = !empty($configuration['created']) ? new \DateTime($configuration['created']) : null;
        $this->updated = !empty($configuration['updated']) ? new \DateTime($configuration['updated']) : null;
        $this->setHtml($configuration['html']);
    }

    /**
     * {@inheritdoc}
     */
    public function __set($property, $value)
    {
        if ($property === 'html') {
            return $this->setHtml($value);
        } else {
            return parent::__set($property, $value);
        }
    }

    /**
     * Set the html value.
     *
     * @param \DOMDocument|string $value
     *   The HTML for the template. The value may be either a string or a
     *   DOMDocument.
     *
     * @return $this
     */
    public function setHtml($value)
    {
        if (is_string($value)) {
            $value = $this->getHtmlObjectFromString($value);
        }

        if (!($value instanceof \DOMDocument)) {
            throw new \InvalidArgumentException('"html" must be set as a valid DOMDocument object.');
        }
        $this->html = $value;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function jsonSerialize()
    {
        return array_filter(parent::jsonSerialize() + [
            'id' => $this->id,
            'name' => $this->name,
            'html' => trim($this->html->saveHtml()),
            'created' => !empty($this->created) ? $this->created->format($this->dateFormat) : null,
            'updated' => !empty($this->updated) ? $this->updated->format($this->dateFormat) : null,
        ]);
    }

    public function getId(): string
    {
        return $this->id;
    }
}<commit_msg>Fixing compatability for PHP5<commit_after><?php

namespace Klaviyo\Model;

/**
 * Simple model that represents a template.
 *
 * @property string $id
 * @property string $name
 * @property \DOMDocument $html
 * @property \DateTimeInterface $created
 * @property \DateTimeInterface $updated
 */
class TemplateModel extends BaseModel implements TemplateIdInterface
{
    protected $id;
    protected $name;
    protected $html;
    protected $created;
    protected $updated;
    protected static $optionalDefaults = [
        'name' => '',
        'created' => null,
        'updated' => null,
    ];
    protected static $mutableAttributes = [
        'html',
    ];

    /**
     * {@inheritdoc}
     */
    public function __construct($configuration)
    {
        parent::__construct($configuration);
        $configuration += self::$optionalDefaults;

        $this->id = $configuration['id'];
        $this->name = $configuration['name'];
        $this->created = !empty($configuration['created']) ? new \DateTime($configuration['created']) : null;
        $this->updated = !empty($configuration['updated']) ? new \DateTime($configuration['updated']) : null;
        $this->setHtml($configuration['html']);
    }

    /**
     * {@inheritdoc}
     */
    public function __set($property, $value)
    {
        if ($property === 'html') {
            return $this->setHtml($value);
        } else {
            return parent::__set($property, $value);
        }
    }

    /**
     * Set the html value.
     *
     * @param \DOMDocument|string $value
     *   The HTML for the template. The value may be either a string or a
     *   DOMDocument.
     *
     * @return $this
     */
    public function setHtml($value)
    {
        if (is_string($value)) {
            $value = $this->getHtmlObjectFromString($value);
        }

        if (!($value instanceof \DOMDocument)) {
            throw new \InvalidArgumentException('"html" must be set as a valid DOMDocument object.');
        }
        $this->html = $value;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function jsonSerialize()
    {
        return array_filter(parent::jsonSerialize() + [
            'id' => $this->id,
            'name' => $this->name,
            'html' => trim($this->html->saveHtml()),
            'created' => !empty($this->created) ? $this->created->format($this->dateFormat) : null,
            'updated' => !empty($this->updated) ? $this->updated->format($this->dateFormat) : null,
        ]);
    }

    public function getId()
    {
        return $this->id;
    }
}
{'fraction_non_alphanumeric': 0.15329733898958736, 'fraction_numerical': 0.0001928268414963363, 'mean_word_length': 2.2975206611570247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '3073284', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1418, 'n_words': 330}