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
63 lines
1.2 KiB
<?php
|
|
|
|
namespace Zitec\RuleEngineBundle\Service;
|
|
|
|
/**
|
|
* This is an example of a context that supports basic global parameters.
|
|
* A real life context would have one or more data sources that it would use read data from.
|
|
*/
|
|
class ContextBase implements RuleContextInterface
|
|
{
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getContextObjectKey(): string
|
|
{
|
|
return RuleContextInterface::CONTEXT;
|
|
}
|
|
|
|
/**
|
|
* @param string $string
|
|
* @return string
|
|
*/
|
|
public function getMethodName(string $string): string
|
|
{
|
|
return 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @return mixed
|
|
*/
|
|
function __get($name)
|
|
{
|
|
$method = $this->getMethodName($name);
|
|
|
|
return $this->$method();
|
|
}
|
|
|
|
/**
|
|
* @return integer
|
|
*/
|
|
public function getCurrentDate(): int
|
|
{
|
|
return time();
|
|
}
|
|
|
|
/**
|
|
* @return integer
|
|
*/
|
|
public function getCurrentDay(): int
|
|
{
|
|
return date('w');
|
|
}
|
|
|
|
/**
|
|
* @return integer
|
|
*/
|
|
public function getCurrentTime(): int
|
|
{
|
|
return strtotime('1970-01-01 ' . date('H:i:s'));
|
|
}
|
|
}
|