PHP Classes

File: exercise/exampletime.php

Recommend this page to a friend!
  Classes of Jorge Castro   Chaos Machine One   exercise/exampletime.php   Download  
File: exercise/exampletime.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Chaos Machine One
Generate random data that obeys to formulas
Author: By
Last change: 1.5
Date: 4 years ago
Size: 753 bytes
 

Contents

Class file image Download
<?php

use eftec\chaosmachineone\ChaosMachineOne;


use
eftec\minilang\MiniLang;
include
"../vendor/autoload.php";

$chaos=new ChaosMachineOne();
$chaos->setDictionary('_index',100);
                                  


// skip next day
// skip next workingday
// skip next weekend
// skip next monday
// skip add 8 hours
// skip next month (first month)


$chaos->table('table',1000)
    ->
field('time','datetime','database',$chaos->now(),0,200)
    ->
gen('when _index=0 then time.speed=3600') // speed is an hour
   
->gen('when time.weekday=5 and time.hour>17 then time.skip="monday" and time.add="8h"') // we skip to the next monday
   
->gen('when time.weekday>=1 and time.weekday<=5 then time.speed=random(1000,3600)')
    ->
show(['time'])
    ->
stat();