<commit_before><?php

namespace Etu\Module\DaymailBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Etu\Core\UserBundle\Entity\Organization;

/**
 * Daymail part
 *
 * @ORM\Table(name="etu_daymail_parts")
 * @ORM\Entity()
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class DaymailPart
{
	/**
	 * @var integer
	 *
	 * @ORM\Column(type="integer")
	 * @ORM\Id
	 * @ORM\GeneratedValue(strategy="AUTO")
	 */
	protected $id;

	/**
	 * @var Organization $orga
	 *
	 * @ORM\ManyToOne(targetEntity="\Etu\Core\UserBundle\Entity\Organization")
	 * @ORM\JoinColumn()
	 */
	protected $orga;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="string", length=50)
	 * @Assert\NotBlank()
	 * @Assert\Length(min = "10", max = "50")
	 */
	protected $title;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="text")
	 * @Assert\NotBlank()
	 * @Assert\Length(min = "15")
	 */
	protected $body;

	/**
	 * @var \DateTime
	 *
	 * @ORM\Column(type="date")
	 */
	protected $date;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="string", length=10)
	 */
	protected $day;

	/**
	 * @var \DateTime $created
	 *
	 * @Gedmo\Timestampable(on="create")
	 * @ORM\Column(type="datetime")
	 */
	protected $createdAt;

	/**
	 * @var \DateTime $updated
	 *
	 * @Gedmo\Timestampable(on="update")
	 * @ORM\Column(type="datetime")
	 */
	protected $updatedAt;

	/**
	 * @var \DateTime $deletedAt
	 *
	 * @ORM\Column(type="datetime", nullable = true)
	 */
	protected $deletedAt;


	/**
	 * @param Organization $orga
	 * @param \DateTime    $date
	 */
	public function __construct(Organization $orga, \DateTime $date)
	{
		$this->orga = $orga;
		$this->setDate($date);
	}

	/**
	 * Create the available list of days which can be used as publish day
	 *
	 * @return \DateTime[]
	 */
	public static function createFutureAvailableDays()
	{
		$available = array();

		for ($i = 1; $i <= 7; $i++) {
			$day = new \DateTime();
			$day->add(new \DateInterval('P'.$i.'D'));

			$available[$day->format('d-m-Y')] = $day;
			$available[$day->format('d-m-Y')]->old = false;
		}

		return $available;
	}

	/**
	 * @param string $body
	 * @return DaymailPart<commit_msg>:lipstick: Update edition time limit for the DayMail<commit_after><?php

namespace Etu\Module\DaymailBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Etu\Core\UserBundle\Entity\Organization;

/**
 * Daymail part
 *
 * @ORM\Table(name="etu_daymail_parts")
 * @ORM\Entity()
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class DaymailPart
{
	/**
	 * @var integer
	 *
	 * @ORM\Column(type="integer")
	 * @ORM\Id
	 * @ORM\GeneratedValue(strategy="AUTO")
	 */
	protected $id;

	/**
	 * @var Organization $orga
	 *
	 * @ORM\ManyToOne(targetEntity="\Etu\Core\UserBundle\Entity\Organization")
	 * @ORM\JoinColumn()
	 */
	protected $orga;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="string", length=50)
	 * @Assert\NotBlank()
	 * @Assert\Length(min = "10", max = "50")
	 */
	protected $title;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="text")
	 * @Assert\NotBlank()
	 * @Assert\Length(min = "15")
	 */
	protected $body;

	/**
	 * @var \DateTime
	 *
	 * @ORM\Column(type="date")
	 */
	protected $date;

	/**
	 * @var string
	 *
	 * @ORM\Column(type="string", length=10)
	 */
	protected $day;

	/**
	 * @var \DateTime $created
	 *
	 * @Gedmo\Timestampable(on="create")
	 * @ORM\Column(type="datetime")
	 */
	protected $createdAt;

	/**
	 * @var \DateTime $updated
	 *
	 * @Gedmo\Timestampable(on="update")
	 * @ORM\Column(type="datetime")
	 */
	protected $updatedAt;

	/**
	 * @var \DateTime $deletedAt
	 *
	 * @ORM\Column(type="datetime", nullable = true)
	 */
	protected $deletedAt;


	/**
	 * @param Organization $orga
	 * @param \DateTime    $date
	 */
	public function __construct(Organization $orga, \DateTime $date)
	{
		$this->orga = $orga;
		$this->setDate($date);
	}

	/**
	 * Create the available list of days which can be used as publish day
	 *
	 * @return \DateTime[]
	 */
	public static function createFutureAvailableDays()
	{
		$available = array();

		for ($i = 1; $i <= 7; $i++) {
			$day = new \DateTime();
			$day->add(new \DateInterval('P'.$i.'D'));

			$available[$day->format('d-m-Y')] = $day;
			$available[$day->format('d-m-Y')]->old = false;
		}

		// Maximum time for edition of daymail
		$current_time = new \DateTime("now");
		$max_edit_time = new \DateTime("today 06:00");
		if($current_time > $max_edit_time)
		{
			$available[$current_time->format('d-m-Y')] = $current_time;
			$available[$current_time->format('d-m-Y')]->old = false;
		}
		return $available;
	}

	/**
	 * @param string $body
	 * @return DaymailPart
{'fraction_non_alphanumeric': 0.19176643562276832, 'fraction_numerical': 0.0058811174123083385, 'mean_word_length': 3.392988929889299, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '1365351', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1682, 'n_words': 321}