Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param string $type
  */
 public function __construct($type)
 {
     if (!Definition\EntityDefinition::exists($type)) {
         throw new \Exception('Unknown entity type: \'' . $type . '\'');
     }
     $this->type = $type;
     $this->uuid = (string) Util\UUID::mint();
     // generate random UUID
     $this->properties = new Collections\ArrayCollection();
     $this->parents = new Collections\ArrayCollection();
 }
Exemplo n.º 2
0
 */
include '../lib/Util/Random.php';
include '../lib/Util/UUID.php';
use Volkszaehler\Model;
use Volkszaehler\Util;
$chars = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'v', 'u', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'V', 'U', 'W', 'X', 'Y', 'Z');
?>
<h4>PRNG tests</h4>

<p>PNRG generator: <?php 
echo Util\Random::init();
?>
</p>

<pre>

<?php 
echo 'Numbers: ' . implode(',', Util\Random::getNumbers(0, 15, 10)) . PHP_EOL;
echo 'String: ' . Util\Random::getString($chars, 100) . PHP_EOL;
echo 'Bytes: ' . Util\Random::getBytes(100) . PHP_EOL;
?>
</pre>
<h4>UUId tests</h4>
<pre>
<?php 
for ($i = 0; $i < 100; $i++) {
    echo Util\UUID::mint(4) . PHP_EOL;
}
?>
</pre>