Hoa central
Even.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Realdom;
38 
39 use Hoa\Math;
40 
49 class Even extends Realdom
50 {
56  const NAME = 'even';
57 
58  /***
59  * Realistic domain defined arguments.
60  *
61  * @var \Hoa\Realdom array
62  */
63  protected $_arguments = [
64  'Integer number'
65  ];
66 
67 
68 
75  protected function _predicate($q)
76  {
77  return $this['number']->predicate($q) && ($q & 1) == 0;
78  }
79 
86  protected function _sample(Math\Sampler $sampler)
87  {
88  $q = $this['number']->sample($sampler);
89 
90  if (($q & 1) == 1) {
91  ++$q;
92  }
93 
94  return $q;
95  }
96 }
const NAME
Definition: Even.php:56
_predicate($q)
Definition: Even.php:75
_sample(Math\Sampler $sampler)
Definition: Even.php:86