Hoa central
Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hoa\Realdom\Date Class Reference
Inheritance diagram for Hoa\Realdom\Date:

Public Attributes

const NAME = 'date'
 
- Public Attributes inherited from Hoa\Realdom\Realdom
const NAME = '(null)'
 

Protected Member Functions

 construct ()
 
 _predicate ($q)
 
 _sample (Math\Sampler $sampler)
 
- Protected Member Functions inherited from Hoa\Realdom\Realdom
 construct ()
 
 setValue ($sampled)
 
 resetArguments ()
 
 _predicate ($q)
 
 _sample (Math\Sampler $sampler)
 
getConstraints ()
 
 _propagateConstraints ($type, $index, Array &$constraints)
 

Protected Attributes

 $_arguments
 
- Protected Attributes inherited from Hoa\Realdom\Realdom
 $_arguments = null
 
 $arguments = null
 
 $__sampler = null
 
 $_value = null
 
 $_constraints = null
 
 $_holder = null
 
 $_constructed = false
 
 $_praspelVisitor = null
 

Static Protected Attributes

static $_constants = null
 
- Static Protected Attributes inherited from Hoa\Realdom\Realdom
static $_sampler = null
 
static $_maxtry = 64
 
static $_defaultPraspelVisitor = null
 

Additional Inherited Members

- Public Member Functions inherited from Hoa\Realdom\Realdom
 __construct ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getArguments ()
 
 count ()
 
 getName ()
 
 setSampler (Math\Sampler $sampler)
 
 getSampler ()
 
 getValue ()
 
 reset ()
 
 predicate ($q)
 
 sample (Math\Sampler $sampler=null)
 
 intersectWith (Realdom $realdom)
 
 setConstraints (Array &$constraints)
 
 propagateConstraints ($type, $index)
 
 is ($qualifier)
 
 setHolder (IRealdom\Holder $holder)
 
 getHolder ()
 
 setPraspelVisitor (Visitor\Visit $visitor)
 
 getPraspelVisitor ()
 
 accept (Visitor\Visit $visitor, &$handle=null, $eldnah=null)
 
- Public Member Functions inherited from Hoa\Visitor\Element
 accept (Visit $visitor, &$handle=null, $eldnah=null)
 
- Static Public Member Functions inherited from Hoa\Realdom\Realdom
static autoBoxing (Array &$arguments, Realdom $self=null)
 
static setDefaultSampler (Math\Sampler $sampler)
 
static getDefaultSampler ()
 
static setMaxTry ($maxtry)
 
static getMaxTry ()
 
static setDefaultPraspelVisitor (Visitor\Visit $visitor)
 
static getDefaultPraspelVisitor ()
 

Detailed Description

Class .

Realistic domain: date.

Definition at line 49 of file Date.php.

Member Function Documentation

Hoa\Realdom\Date::_predicate (   $q)
protected

Predicate whether the sampled value belongs to the realistic domains.

Parameters
mixed$qSampled value.
Returns
boolean

Definition at line 119 of file Date.php.

120  {
121  $format = $this['format']->getConstantValue();
122 
123  try {
124  $datetime = \DateTime::createFromFormat($format, $q);
125  } catch (\Exception $e) {
126  return false;
127  }
128 
129  return
130  false !== $datetime &&
131  $this['timestamp']->predicate(intval($datetime->format('U')));
132  }
Hoa\Realdom\Date::_sample ( Math\Sampler  $sampler)
protected

Sample one new value.

Parameters
\Hoa\Math\Sampler$samplerSampler.
Returns
mixed

Definition at line 140 of file Date.php.

141  {
142  return date(
143  $this['format']->getConstantValue(),
144  $this['timestamp']->sample($sampler)
145  );
146  }
sample(Math\Sampler $sampler=null)
Definition: Realdom.php:686

Here is the call graph for this function:

Hoa\Realdom\Date::construct ( )
protected

Construct a realistic domain.

Returns
void

Definition at line 83 of file Date.php.

84  {
85  if (null === static::$_constants) {
86  $reflection = new \ReflectionClass('DateTime');
87  static::$_constants = $reflection->getConstants();
88  }
89 
90  $constants = &static::$_constants;
91  $this['format']['value'] = preg_replace_callback(
92  '#__(\w+)__#',
93  function (Array $matches) use (&$constants) {
94  $c = $matches[1];
95 
96  if (!isset($constants[$c])) {
97  return $matches[0];
98  }
99 
100  return $constants[$c];
101  },
102  $this['format']->getConstantValue()
103  );
104 
105  if ($this['timestamp'] instanceof Constinteger &&
106  -1 === $this['timestamp']->getConstantValue()) {
107  $this['timestamp'] = new Constinteger(time());
108  }
109 
110  return;
111  }

Member Data Documentation

Hoa\Realdom\Date::$_arguments
protected
Initial value:
= [
'RealdomString format' => 'c'

Definition at line 71 of file Date.php.

Hoa\Realdom\Date::$_constants = null
staticprotected

Definition at line 64 of file Date.php.

const Hoa\Realdom\Date::NAME = 'date'

Realistic domain name.

string

Definition at line 56 of file Date.php.


The documentation for this class was generated from the following file: