<commit_before><?php

namespace Rhubarb\Scaffolds\Communications\Models;

use Rhubarb\Crown\DateTime\RhubarbDate;
use Rhubarb\Crown\DateTime\RhubarbDateTime;
use Rhubarb\Stem\Collections\Collection;
use Rhubarb\Stem\Exceptions\ModelConsistencyValidationException;
use Rhubarb\Stem\Filters\AndGroup;
use Rhubarb\Stem\Filters\Equals;
use Rhubarb\Stem\Models\Model;
use Rhubarb\Stem\Repositories\MySql\Schema\Columns\MySqlEnumColumn;
use Rhubarb\Stem\Schema\Columns\AutoIncrementColumn;
use Rhubarb\Stem\Schema\Columns\DateTimeColumn;
use Rhubarb\Stem\Schema\Columns\StringColumn;
use Rhubarb\Stem\Schema\ModelSchema;

/**
 * @property int $CommunicationID
 * @property string $Title
 * @property string $Status
 * @property RhubarbDateTime $DateCreated
 * @property RhubarbDateTime $DateSent
 * @property RhubarbDateTime $DateToSend
 *
 * @property CommunicationItem[]|Collection $Items The items connected with the communication
 */
class Communication extends Model
{
    const STATUS_DRAFT = "Draft";
    const STATUS_SCHEDULED = "Scheduled";
    const STATUS_SENT = "Sent";
    const STATUS_FAILED = 'Failed';

    public function setDateSent($newValue)
    {
        throw new ModelConsistencyValidationException();
    }

    public function markSent()
    {
        $this->Status = self::STATUS_SENT;
        $this->modelData["DateSent"] = new RhubarbDate("now");
        $this->save();
    }

    protected function createSchema()
    {
        $schema = new ModelSchema("tblCommunication");

        $schema->addColumn(
            new AutoIncrementColumn("CommunicationID"),
            new StringColumn("Title", 150),
            new MySqlEnumColumn("Status", self::STATUS_DRAFT, [self::STATUS_DRAFT, self::STATUS_SCHEDULED, self::STATUS_SENT, self::STATUS_FAILED]),
            new DateTimeColumn("DateCreated"),
            new DateTimeColumn("DateSent"),<commit_msg>Set a time, not just a date<commit_after><?php

namespace Rhubarb\Scaffolds\Communications\Models;

use Rhubarb\Crown\DateTime\RhubarbDate;
use Rhubarb\Crown\DateTime\RhubarbDateTime;
use Rhubarb\Stem\Collections\Collection;
use Rhubarb\Stem\Exceptions\ModelConsistencyValidationException;
use Rhubarb\Stem\Filters\AndGroup;
use Rhubarb\Stem\Filters\Equals;
use Rhubarb\Stem\Models\Model;
use Rhubarb\Stem\Repositories\MySql\Schema\Columns\MySqlEnumColumn;
use Rhubarb\Stem\Schema\Columns\AutoIncrementColumn;
use Rhubarb\Stem\Schema\Columns\DateTimeColumn;
use Rhubarb\Stem\Schema\Columns\StringColumn;
use Rhubarb\Stem\Schema\ModelSchema;

/**
 * @property int $CommunicationID
 * @property string $Title
 * @property string $Status
 * @property RhubarbDateTime $DateCreated
 * @property RhubarbDateTime $DateSent
 * @property RhubarbDateTime $DateToSend
 *
 * @property CommunicationItem[]|Collection $Items The items connected with the communication
 */
class Communication extends Model
{
    const STATUS_DRAFT = "Draft";
    const STATUS_SCHEDULED = "Scheduled";
    const STATUS_SENT = "Sent";
    const STATUS_FAILED = 'Failed';

    public function setDateSent($newValue)
    {
        throw new ModelConsistencyValidationException();
    }

    public function markSent()
    {
        $this->Status = self::STATUS_SENT;
        $this->modelData["DateSent"] = new RhubarbDateTime("now");
        $this->save();
    }

    protected function createSchema()
    {
        $schema = new ModelSchema("tblCommunication");

        $schema->addColumn(
            new AutoIncrementColumn("CommunicationID"),
            new StringColumn("Title", 150),
            new MySqlEnumColumn("Status", self::STATUS_DRAFT, [self::STATUS_DRAFT, self::STATUS_SCHEDULED, self::STATUS_SENT, self::STATUS_FAILED]),
            new DateTimeColumn("DateCreated"),
            new DateTimeColumn("DateSent"),
{'fraction_non_alphanumeric': 0.10890302066772654, 'fraction_numerical': 0.001589825119236884, 'mean_word_length': 4.2945301542777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '491995', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1139, 'n_words': 221}