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

Public Member Functions

 discredit ($value)
 
 getSize ()
 
- 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)
 

Public Attributes

const NAME = 'string'
 
- 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
 
 $_discredited = []
 
- Protected Attributes inherited from Hoa\Realdom\Realdom
 $_arguments = null
 
 $arguments = null
 
 $__sampler = null
 
 $_value = null
 
 $_constraints = null
 
 $_holder = null
 
 $_constructed = false
 
 $_praspelVisitor = null
 

Additional Inherited Members

- 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 ()
 
- Static Protected Attributes inherited from Hoa\Realdom\Realdom
static $_sampler = null
 
static $_maxtry = 64
 
static $_defaultPraspelVisitor = null
 

Detailed Description

Class .

Realistic domain: string.

Definition at line 50 of file RealdomString.php.

Member Function Documentation

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

Predicate whether the sampled value belongs to the realistic domains.

Parameters
mixed$qSampled value.
Returns
boolean

Definition at line 108 of file RealdomString.php.

109  {
110  if (!is_string($q)) {
111  return false;
112  }
113 
114  $length = mb_strlen($q);
115 
116  if (false === $this['length']->predicate($length)) {
117  return false;
118  }
119 
120  if (0 === $length) {
121  return true;
122  }
123 
124  $split = preg_split('#(?<!^)(?!$)#u', $q);
125  $out = true;
126  $handle = 0;
127  $min = $this['codepointMin']->getConstantValue();
128  $max = $this['codepointMax']->getConstantValue();
129 
130  foreach ($split as $letter) {
131  $handle = Ustring::toCode($letter);
132  $out = $out && ($min <= $handle) && ($handle <= $max);
133  }
134 
135  return $out;
136  }
static toCode($char)
Definition: Ustring.php:943

Here is the call graph for this function:

Hoa\Realdom\RealdomString::_sample ( Math\Sampler  $sampler)
protected

Sample one new value.

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

Definition at line 144 of file RealdomString.php.

145  {
146  $string = null;
147  $min = $this['codepointMin']->getConstantValue();
148  $max = $this['codepointMax']->getConstantValue();
149  $length = $this['length']->sample($sampler);
150 
151  if (0 > $length) {
152  return false;
153  }
154 
155  for ($i = 0; $i < $length; ++$i) {
156  $string .= Ustring::fromCode($sampler->getInteger(
157  $min,
158  $max,
159  $this->_discredited
160  ));
161  }
162 
163  return $string;
164  }
static fromCode($code)
Definition: Ustring.php:928

Here is the call graph for this function:

Hoa\Realdom\RealdomString::construct ( )
protected

Construct a realistic domain.

Returns
void

Definition at line 87 of file RealdomString.php.

88  {
89  if ($this['codepointMin'] instanceof Conststring) {
90  $char = mb_substr($this['codepointMin']->getConstantValue(), 0, 1);
91  $this['codepointMin'] = new Constinteger(Ustring::toCode($char));
92  }
93 
94  if ($this['codepointMax'] instanceof Conststring) {
95  $char = mb_substr($this['codepointMax']->getConstantValue(), 0, 1);
96  $this['codepointMax'] = new Constinteger(Ustring::toCode($char));
97  }
98 
99  return;
100  }
static toCode($char)
Definition: Ustring.php:943

Here is the call graph for this function:

Hoa\Realdom\RealdomString::discredit (   $value)

Discredit a value.

Parameters
mixed$valueValue to discredit.
Returns

Implements Hoa\Realdom\IRealdom\Nonconvex.

Definition at line 172 of file RealdomString.php.

173  {
174  $_value = Ustring::toCode($value);
175 
176  if (true === in_array($_value, $this->_discredited) ||
177  false === $this->predicate($value)) {
178  return $this;
179  }
180 
181  $this->_discredited[] = $_value;
182 
183  return $this;
184  }
static toCode($char)
Definition: Ustring.php:943

Here is the call graph for this function:

Hoa\Realdom\RealdomString::getSize ( )

Get size of the domain.

Returns
int

Implements Hoa\Realdom\IRealdom\Finite.

Definition at line 191 of file RealdomString.php.

192  {
193 
194  // @TODO : this is only for length=1.
195  return
196  $this['codepointMax']->getConstantValue() -
197  $this['codepointMin']->getConstantValue() -
198  count($this->_discredited) + 1;
199  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Realdom\RealdomString::$_arguments
protected
Initial value:
= [
'Constinteger|Conststring codepointMin' => 0x20

Definition at line 67 of file RealdomString.php.

Hoa\Realdom\RealdomString::$_discredited = []
protected

Definition at line 78 of file RealdomString.php.

const Hoa\Realdom\RealdomString::NAME = 'string'

Realistic domain name.

string

Definition at line 60 of file RealdomString.php.


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