DateIntervalFactory.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Dotdigitalgroup\Email\Model;
  3. /**
  4. * Factory class for creating DateInterval object
  5. */
  6. class DateIntervalFactory
  7. {
  8. /**
  9. * Object Manager instance
  10. *
  11. * @var \Magento\Framework\ObjectManagerInterface
  12. */
  13. private $_objectManager = null;
  14. /**
  15. * @var null|string
  16. */
  17. private $_instanceName = null;
  18. /**
  19. * Factory constructor
  20. *
  21. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  22. * @param string $instanceName
  23. */
  24. public function __construct(
  25. \Magento\Framework\ObjectManagerInterface $objectManager,
  26. $instanceName = '\\DateInterval'
  27. ) {
  28. $this->_instanceName = $instanceName;
  29. $this->_objectManager = $objectManager;
  30. }
  31. /**
  32. * Create DateInterval object with specified parameters
  33. *
  34. * @param array $data
  35. * @return \DateInterval
  36. */
  37. public function create(array $data = [])
  38. {
  39. return $this->_objectManager->create('\\DateInterval', $data);
  40. }
  41. }