Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.2 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Service;
  3. /**
  4. * This is an example of a context that supports basic global parameters.
  5. * A real life context would have one or more data sources that it would use read data from.
  6. */
  7. class ContextBase implements RuleContextInterface
  8. {
  9. /**
  10. * @return string
  11. */
  12. public function getContextObjectKey(): string
  13. {
  14. return RuleContextInterface::CONTEXT;
  15. }
  16. /**
  17. * @param string $string
  18. * @return string
  19. */
  20. public function getMethodName(string $string): string
  21. {
  22. return 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
  23. }
  24. /**
  25. * @param string $name
  26. * @return mixed
  27. */
  28. function __get($name)
  29. {
  30. $method = $this->getMethodName($name);
  31. return $this->$method();
  32. }
  33. /**
  34. * @return integer
  35. */
  36. public function getCurrentDate(): int
  37. {
  38. return time();
  39. }
  40. /**
  41. * @return integer
  42. */
  43. public function getCurrentDay(): int
  44. {
  45. return date('w');
  46. }
  47. /**
  48. * @return integer
  49. */
  50. public function getCurrentTime(): int
  51. {
  52. return strtotime('1970-01-01 ' . date('H:i:s'));
  53. }
  54. }