Lines 100.00% 1 / 1
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
51class TimelineEvent
52{
53    public const string READ = 'timeline_event:read';
54
55    public const string WRITE = 'timeline_event:write';
56
57    public const string DATE_FORMAT = 'Y-m-d';
58
59    #[Column, Id, GeneratedValue]
60    #[Groups([self::READ])]
61    public ?int $id = null;
62
63    /** Set on creation: by the form's controller, or TimelineEventProcessor for the API. */
64    #[ManyToOne, JoinColumn(nullable: false, onDelete: 'CASCADE'), Ignore]
65    public ?User $owner = null;
66
67    #[Column(type: Types::DATE_IMMUTABLE)]
68    #[Context([DateTimeNormalizer::FORMAT_KEY => self::DATE_FORMAT])]
69    #[Groups([self::READ, self::WRITE])]
70    #[Assert\NotNull]
71    public ?\DateTimeImmutable $date = null;
72
73    /** The last day of an event over several days; null for a single day. */
74    #[Column(type: Types::DATE_IMMUTABLE, nullable: true)]
75    #[Context([DateTimeNormalizer::FORMAT_KEY => self::DATE_FORMAT])]
76    #[Groups([self::READ, self::WRITE])]
77    #[Assert\GreaterThanOrEqual(propertyPath: 'date', message: 'The end date must not be before the date.')]
78    public ?\DateTimeImmutable $endDate = null;
79
80    #[Column(length: 500)]
81    #[Groups([self::READ, self::WRITE])]
82    #[Assert\NotBlank(normalizer: 'trim'), Assert\Length(max: 500)]
83    public string $text = '';
84
85    #[Column(type: Types::DATETIME_IMMUTABLE)]
86    #[Ignore]
87    public private(set) \DateTimeImmutable $createdAt;
88
89    public function __construct()
90    {
91        $this->createdAt = new \DateTimeImmutable();
92    }
93}