1: <?php
2: declare(strict_types=1);
3:
4: namespace om\ICal;
5:
6: use DateInterval;
7: use DateTimeInterface;
8: use InvalidArgumentException;
9: use om\ICal\Value\CalAddress;
10: use om\ICal\Value\Classification;
11: use om\ICal\Value\DateTimeValue;
12: use om\ICal\Value\Image;
13: use om\ICal\Value\Link;
14: use om\ICal\Value\Period;
15: use om\ICal\Value\PropertyFactory;
16: use om\ICal\Value\Relation;
17: use om\ICal\Value\Status;
18: use om\RRule\Rule;
19:
20: /**
21: * VJOURNAL (RFC 5545, section 3.6.3). A journal entry has no duration.
22: *
23: * @phpstan-import-type PropertyList from PropertyFactory
24: */
25: final class Journal extends Item {
26: /**
27: * A new journal entry; the arguments are those of Event::new() without the end, the location
28: * and the alarms (a journal entry has none).
29: *
30: * @param ?string $uid UID, a random UUID when null
31: * @param DateTimeInterface|DateTimeValue|string|null $stamp DTSTAMP, now when null; written in UTC
32: * @param DateTimeInterface|DateTimeValue|string|null $start DTSTART: a DateTimeInterface (TZID of its IANA timezone or UTC), a DateTimeValue (also a DATE or a floating time) or an iCalendar string
33: * @param Status|string|null $status DRAFT, FINAL or CANCELLED
34: * @param Classification|string|null $classification
35: * @param iterable<string> $categories
36: * @param CalAddress|string|null $organizer
37: * @param iterable<CalAddress|string> $attendees
38: * @param Rule|string|null $rrule
39: * @param iterable<DateTimeInterface|DateTimeValue|Period|string> $rdates
40: * @param iterable<DateTimeInterface|DateTimeValue|string> $exdates
41: * @param DateTimeInterface|DateTimeValue|string|null $recurrenceId
42: * @param iterable<Image|string> $images
43: * @param iterable<Link|string> $links
44: * @param iterable<Relation|string> $relatedTo
45: * @param PropertyList $properties
46: * @throws InvalidArgumentException for an invalid value or combination of arguments
47: */
48: public static function new(
49: ?string $uid = null,
50: DateTimeInterface|DateTimeValue|string|null $stamp = null,
51: DateTimeInterface|DateTimeValue|string|null $start = null,
52: ?string $summary = null,
53: ?string $description = null,
54: ?string $url = null,
55: Status|string|null $status = null,
56: Classification|string|null $classification = null,
57: ?int $sequence = null,
58: iterable $categories = [],
59: CalAddress|string|null $organizer = null,
60: iterable $attendees = [],
61: Rule|string|null $rrule = null,
62: iterable $rdates = [],
63: iterable $exdates = [],
64: DateTimeInterface|DateTimeValue|string|null $recurrenceId = null,
65: ?string $color = null,
66: iterable $images = [],
67: iterable $links = [],
68: iterable $relatedTo = [],
69: array $properties = [],
70: ): self {
71: $builder = ComponentBuilder::item('VJOURNAL', $uid, $stamp);
72: $startValue = $builder->start($start);
73: $builder->recurrence($startValue, $rrule, $rdates, $exdates, $recurrenceId)
74: ->descriptive(summary: $summary, description: $description, url: $url, classification: $classification, sequence: $sequence, categories: $categories, organizer: $organizer, attendees: $attendees, color: $color, images: $images, links: $links, relatedTo: $relatedTo)
75: ->status($status);
76: return new self($builder->build($properties), new Calendar());
77: }
78:
79: public function duration(): DateInterval {
80: return new DateInterval('PT0S');
81: }
82: }
83: