Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class data

Helixdata
Hide Inherited MembersHelix Core
Description
No description.
 
Constants
No constants.
 
Properties
 
Methods
public staticrand ( min [0] , max [1] )[ data ]
Parameters
optionalmin [0]
optionalmax [1]
Code
035  public static function rand($__min=0,$__max=1)
036  {
037      return rand($__min,$__max);
038  }
public staticrand_city ( )[ data ]
Parameters
No parameters for this method
Code
070  public static function rand_city()
071  {
072      $data = file_get_contents(SITES . "helix/resources/docs/cities.txt");
073      $array = split(",",$data);
074      return $array[rand(0,count($array)-1)];
075  }
public staticrand_date ( fromdate , todate , format ["Y-m-d"] )[ data ]
Parameters
optionalfromdate
optionaltodate
optionalformat ["Y-m-d"]
Code
004  public static function rand_date($__fromdate=null,$__todate=null,$__format="Y-m-d")
005  {
006      //convert date to numbers
007      if($__fromdate)
008      {
009          $__fromdate=strtotime($__fromdate);
010      }
011      else
012      {
013          $__fromdate=0;
014      }
015      if($__todate)
016      {
017          $__todate=strtotime($__todate);
018      }
019      else
020      {
021          $__todate=time();
022      }
023     
024      $time = rand($__fromdate , $__todate);
025      return date($__format, $time);
026  }
public staticrand_datetime ( fromdatetime , todatetime )[ data ]
Parameters
optionalfromdatetime
optionaltodatetime
Code
027  public static function rand_datetime($__fromdatetime=null,$__todatetime=null)
028  {
029      return data::rand_date($__fromdatetime,$__todatetime,"Y-m-d H:i:s");
030  }
public staticrand_first_name ( gender )[ data ]
Parameters
optionalgender
Code
076  public static function rand_first_name($__gender=null)
077  {
078      if($__gender=="male")
079      {
080          $data = file_get_contents(SITES . "helix/resources/docs/male_first_names.txt");
081      }
082      elseif ($__gender=="female")
083      {
084          $data = file_get_contents(SITES . "helix/resources/docs/female_first_names.txt");
085      }
086      else {
087          $data = file_get_contents(SITES . "helix/resources/docs/first_names.txt");
088      }
089      $array = split(",",$data);
090      return $array[rand(0,count($array)-1)];
091  }
public staticrand_last_name ( )[ data ]
Parameters
No parameters for this method
Code
064  public static function rand_last_name()
065  {
066      $data = file_get_contents(SITES . "helix/resources/docs/last_names.txt");
067      $array = split(",",$data);
068      return $array[rand(0,count($array)-1)];
069  }
public staticrand_time ( )[ data ]
Parameters
No parameters for this method
Code
031  public static function rand_time()
032  {
033      return data::rand_date(null,null,"H:i:s");
034  }
public staticrand_type ( )[ data ]
Parameters
No parameters for this method
Code
060  public static function rand_type()
061  {
062      return preg_replace("/[^a-zA-Z]/","",strtolower(data::rand_words(1,1)));
063  }
public staticrand_words ( min [1] , max [1] )[ data ]
Parameters
optionalmin [1]
optionalmax [1]
Code
039  public static function rand_words($__min=1,$__max=1)
040  {
041      if($__max<$__min)
042      {
043          return false;
044      }
045     
046      $return="";
047      $length = $__max-$__min+1;
048      $starting_point = rand(0,1000-$length);//the input file has 1000 words, so it has to start before that
049      $ending_point = $starting_point + rand($__min,$__max);
050     
051      $words = file_get_contents(SITES . "helix/resources/docs/loremipsum.txt");
052      $word_array = split(" ",$words);
053     
054      for($i=$starting_point;$i<$ending_point;$i++)
055      {
056          $return .= $word_array[$i]." ";
057      }
058      return $return;
059  }
 
Accessors
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads