OutlookCalendarFactory.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Factory\Outlook; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 6 | use AmeliaBooking\Domain\Entity\Outlook\OutlookCalendar; |
| 7 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 8 | use AmeliaBooking\Domain\ValueObjects\String\Label; |
| 9 | use AmeliaBooking\Domain\ValueObjects\String\Token; |
| 10 | |
| 11 | /** |
| 12 | * Class OutlookCalendarFactory |
| 13 | * |
| 14 | * @package AmeliaBooking\Domain\Factory\Outlook |
| 15 | */ |
| 16 | class OutlookCalendarFactory |
| 17 | { |
| 18 | /** |
| 19 | * @param $data |
| 20 | * |
| 21 | * @return OutlookCalendar |
| 22 | * @throws InvalidArgumentException |
| 23 | */ |
| 24 | public static function create($data) |
| 25 | { |
| 26 | $outlookCalendar = new OutlookCalendar( |
| 27 | new Token($data['token']), |
| 28 | new Label(empty($data['calendarId']) ? null : $data['calendarId']) |
| 29 | ); |
| 30 | |
| 31 | if (isset($data['id'])) { |
| 32 | $outlookCalendar->setId(new Id($data['id'])); |
| 33 | } |
| 34 | if (isset($data['insertPendingAppointments'])) { |
| 35 | $outlookCalendar->setInsertPendingAppointments((bool)$data['insertPendingAppointments']); |
| 36 | } |
| 37 | |
| 38 | if (isset($data['includeBufferTime'])) { |
| 39 | $outlookCalendar->setIncludeBufferTime((bool)$data['includeBufferTime']); |
| 40 | } |
| 41 | |
| 42 | if (isset($data['title'])) { |
| 43 | $outlookCalendar->setTitle($data['title']); |
| 44 | } |
| 45 | |
| 46 | if (isset($data['description'])) { |
| 47 | $outlookCalendar->setDescription($data['description']); |
| 48 | } |
| 49 | |
| 50 | return $outlookCalendar; |
| 51 | } |
| 52 | } |
| 53 |