OpenTracking.php 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * Copyright (C) 2013 Mailgun
  5. *
  6. * This software may be modified and distributed under the terms
  7. * of the MIT license. See the LICENSE file for details.
  8. */
  9. namespace Mailgun\Model\Domain;
  10. /**
  11. * Represents a single Open Tracking setting for a domain tracking.
  12. *
  13. * @author Artem Bondarenko <artem@uartema.com>
  14. */
  15. final class OpenTracking
  16. {
  17. private ?string $active;
  18. public static function create(array $data): self
  19. {
  20. $active = $data['active'] ?? null;
  21. $model = new self();
  22. $model->active = $active ? 'yes' : 'no';
  23. return $model;
  24. }
  25. private function __construct()
  26. {
  27. }
  28. /**
  29. * @return string|null
  30. */
  31. public function getActive(): ?string
  32. {
  33. return $this->active;
  34. }
  35. /**
  36. * @return bool
  37. */
  38. public function isActive(): bool
  39. {
  40. return 'yes' === $this->getActive();
  41. }
  42. }