Skip to content

Commit

Permalink
Added attendee Object (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
giorginogreg authored Oct 29, 2021
1 parent 1d10d38 commit a5c57b2
Show file tree
Hide file tree
Showing 17 changed files with 1,144 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea
/.vscode
/*.cache
/build
/Makefile.local
Expand Down
39 changes: 21 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Event Attendee property [#333](https://github.com/markuspoerschke/iCal/pull/314)

### Fixed

- PHPStan complains about wrongly typed hinted constructor argument of `Calendar` class. [#281](https://github.com/markuspoerschke/iCal/issues/281)
Expand Down Expand Up @@ -203,25 +207,24 @@ Please check the [upgrade guide](UPGRADE.md) on how to upgrade from version `0.*
- **Breaking Change:** Changed signature of the `Event::setOrganizer` method. Now there is is only one parameter that must be an instance of `Property\Organizer`.
- Updated install section in README.md [#54](https://github.com/markuspoerschke/iCal/pull/53)

[0.9.0]: https://github.com/markuspoerschke/iCal/compare/0.8.0...0.9.0
[0.10.0]: https://github.com/markuspoerschke/iCal/compare/0.9.0...0.10.0
[0.10.1]: https://github.com/markuspoerschke/iCal/compare/0.10.0...0.10.1
[0.11.0]: https://github.com/markuspoerschke/iCal/compare/0.10.1...0.11.0
[0.11.1]: https://github.com/markuspoerschke/iCal/compare/0.11.0...0.11.1
[0.11.2]: https://github.com/markuspoerschke/iCal/compare/0.11.1...0.11.2
[0.11.3]: https://github.com/markuspoerschke/iCal/compare/0.11.2...0.11.3
[0.11.4]: https://github.com/markuspoerschke/iCal/compare/0.11.3...0.11.4
[0.11.5]: https://github.com/markuspoerschke/iCal/compare/0.11.4...0.11.5
[0.12.0]: https://github.com/markuspoerschke/iCal/compare/0.11.0...0.12.0
[0.12.1]: https://github.com/markuspoerschke/iCal/compare/0.12.0...0.12.1
[0.13.0]: https://github.com/markuspoerschke/iCal/compare/0.12.1...0.13.0
[0.14.0]: https://github.com/markuspoerschke/iCal/compare/0.13.0...0.14.0
[0.15.0]: https://github.com/markuspoerschke/iCal/compare/0.14.0...0.15.0
[0.15.1]: https://github.com/markuspoerschke/iCal/compare/0.15.0...0.15.1
[0.16.0]: https://github.com/markuspoerschke/iCal/compare/0.15.1...0.16.0
[unreleased]: https://github.com/markuspoerschke/iCal/compare/2.3.0...HEAD
[2.3.0]: https://github.com/markuspoerschke/iCal/compare/2.2.0...2.3.0
[2.2.0]: https://github.com/markuspoerschke/iCal/compare/2.1.0...2.2.0
[2.0.0]: https://github.com/markuspoerschke/iCal/compare/0.16.0...2.0.0
[unreleased]: https://github.com/markuspoerschke/iCal/compare/2.1.0...HEAD
[2.1.0]: https://github.com/markuspoerschke/iCal/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/markuspoerschke/iCal/compare/0.16.0...2.0.0
[0.16.0]: https://github.com/markuspoerschke/iCal/compare/0.15.1...0.16.0
[0.15.1]: https://github.com/markuspoerschke/iCal/compare/0.15.0...0.15.1
[0.15.0]: https://github.com/markuspoerschke/iCal/compare/0.14.0...0.15.0
[0.14.0]: https://github.com/markuspoerschke/iCal/compare/0.13.0...0.14.0
[0.13.0]: https://github.com/markuspoerschke/iCal/compare/0.12.1...0.13.0
[0.12.1]: https://github.com/markuspoerschke/iCal/compare/0.12.0...0.12.1
[0.12.0]: https://github.com/markuspoerschke/iCal/compare/0.11.0...0.12.0
[0.11.5]: https://github.com/markuspoerschke/iCal/compare/0.11.4...0.11.5
[0.11.4]: https://github.com/markuspoerschke/iCal/compare/0.11.3...0.11.4
[0.11.3]: https://github.com/markuspoerschke/iCal/compare/0.11.2...0.11.3
[0.11.2]: https://github.com/markuspoerschke/iCal/compare/0.11.1...0.11.2
[0.11.1]: https://github.com/markuspoerschke/iCal/compare/0.11.0...0.11.1
[0.11.0]: https://github.com/markuspoerschke/iCal/compare/0.10.1...0.11.0
[0.10.0]: https://github.com/markuspoerschke/iCal/compare/0.9.0...0.10.0
[0.10.1]: https://github.com/markuspoerschke/iCal/compare/0.10.0...0.10.1
[0.9.0]: https://github.com/markuspoerschke/iCal/compare/0.8.0...0.9.0
271 changes: 271 additions & 0 deletions src/Domain/Entity/Attendee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
<?php

/*
* This file is part of the eluceo/iCal package.
*
* (c) 2021 Markus Poerschke <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Eluceo\iCal\Domain\Entity;

use Eluceo\iCal\Domain\Enum\CalendarUserType;
use Eluceo\iCal\Domain\Enum\ParticipationStatus;
use Eluceo\iCal\Domain\Enum\RoleType;
use Eluceo\iCal\Domain\ValueObject\EmailAddress;
use Eluceo\iCal\Domain\ValueObject\Member;
use Eluceo\iCal\Domain\ValueObject\Uri;

/**
* @see https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.4.1
*/
final class Attendee
{
private EmailAddress $emailAddress;
private ?CalendarUserType $calendarUserType = null;
private ?RoleType $role = null;
private ?ParticipationStatus $participationStatus = null;
private ?bool $rsvp = null;
private ?string $displayName = null;
private ?Uri $directoryEntry = null;
private ?string $language = null;

/**
* @var array<Member>
*/
private array $members = [];

/**
* @var array<EmailAddress>
*/
private array $delegatedTo = [];

/**
* @var array<EmailAddress>
*/
private array $delegatedFrom = [];

/**
* @var array<EmailAddress>
*/
private array $sentBy = [];

public function __construct(
EmailAddress $emailAddress
) {
$this->emailAddress = $emailAddress;
}

public function getEmailAddress(): EmailAddress
{
return $this->emailAddress;
}

public function setCalendarUserType(CalendarUserType $calendarUserType): self
{
$this->calendarUserType = $calendarUserType;

return $this;
}

public function hasCalendarUserType(): bool
{
return $this->calendarUserType !== null;
}

public function getCalendarUserType(): CalendarUserType
{
assert($this->calendarUserType !== null);

return $this->calendarUserType;
}

public function hasMembers(): bool
{
return !empty($this->members);
}

public function addMember(Member $member): self
{
$this->members[] = $member;

return $this;
}

/**
* @return array<Member>
*/
public function getMembers(): array
{
return $this->members;
}

public function setRole(RoleType $role): self
{
$this->role = $role;

return $this;
}

public function hasRole(): bool
{
return $this->role !== null;
}

public function getRole(): RoleType
{
assert($this->role !== null);

return $this->role;
}

public function setParticipationStatus(ParticipationStatus $participationStatus): self
{
$this->participationStatus = $participationStatus;

return $this;
}

public function hasParticipationStatus(): bool
{
return $this->participationStatus !== null;
}

public function getParticipationStatus(): ParticipationStatus
{
assert($this->participationStatus !== null);

return $this->participationStatus;
}

public function setResponseNeededFromAttendee(bool $res): self
{
$this->rsvp = $res;

return $this;
}

public function isRSVPenabled(): bool
{
return $this->rsvp !== null;
}

public function setDisplayName(string $displayName): self
{
$this->displayName = $displayName;

return $this;
}

public function hasDisplayName(): bool
{
return $this->displayName !== null;
}

public function getDisplayName(): string
{
assert($this->displayName !== null);

return $this->displayName;
}

public function addDelegatedTo(EmailAddress $delegatedTo): self
{
$this->delegatedTo[] = $delegatedTo;

return $this;
}

public function hasDelegatedTo(): bool
{
return !empty($this->delegatedTo);
}

/**
* @return array<EmailAddress>
*/
public function getDelegatedTo(): array
{
return $this->delegatedTo;
}

public function addDelegatedFrom(EmailAddress $delegatedFrom): self
{
$this->delegatedFrom[] = $delegatedFrom;

return $this;
}

public function hasDelegatedFrom(): bool
{
return !empty($this->delegatedFrom);
}

/**
* @return array<EmailAddress>
*/
public function getDelegatedFrom(): array
{
return $this->delegatedFrom;
}

public function addSentBy(EmailAddress $sentBy): self
{
$this->sentBy[] = $sentBy;

return $this;
}

public function hasSentBy(): bool
{
return !empty($this->sentBy);
}

/**
* @return array<EmailAddress>
*/
public function getSentBy(): array
{
return $this->sentBy;
}

public function hasDirectoryEntryReference(): bool
{
return $this->directoryEntry !== null;
}

public function getDirectoryEntryReference(): Uri
{
assert($this->directoryEntry !== null);

return $this->directoryEntry;
}

public function setDirectoryEntryReference(Uri $directoryEntry): self
{
$this->directoryEntry = $directoryEntry;

return $this;
}

public function hasLanguage(): bool
{
return $this->language !== null;
}

public function getLanguage(): string
{
assert($this->language !== null);

return $this->language;
}

public function setLanguage(string $language): self
{
$this->language = $language;

return $this;
}
}
35 changes: 35 additions & 0 deletions src/Domain/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class Event
private ?Organizer $organizer = null;
private ?Timestamp $lastModified = null;

/**
* @var array<Attendee>
*/
private array $attendees = [];

/**
* @var array<Alarm>
*/
Expand Down Expand Up @@ -248,4 +253,34 @@ public function setLastModified(?Timestamp $lastModified): self

return $this;
}

public function hasAttendee(): bool
{
return !empty($this->attendees);
}

public function addAttendee(Attendee $attendee): self
{
$this->attendees[] = $attendee;

return $this;
}

/**
* @param Attendee[] $attendees
*/
public function setAttendees(array $attendees): self
{
$this->attendees = $attendees;

return $this;
}

/**
* @return Attendee[]
*/
public function getAttendees(): array
{
return $this->attendees;
}
}
Loading

0 comments on commit a5c57b2

Please sign in to comment.