|
@@ -12,7 +12,7 @@ class Random {
|
|
|
/**
|
|
/**
|
|
|
* @param int $min
|
|
* @param int $min
|
|
|
* @param int $max
|
|
* @param int $max
|
|
|
- * @return random int value
|
|
|
|
|
|
|
+ * @return int Random int value
|
|
|
*/
|
|
*/
|
|
|
public static function int($min = 0, $max = 999) {
|
|
public static function int($min = 0, $max = 999) {
|
|
|
return mt_rand($min, $max);
|
|
return mt_rand($min, $max);
|
|
@@ -21,7 +21,7 @@ class Random {
|
|
|
/**
|
|
/**
|
|
|
* @param float $min
|
|
* @param float $min
|
|
|
* @param float $max
|
|
* @param float $max
|
|
|
- * @return random float value
|
|
|
|
|
|
|
+ * @return random Float value
|
|
|
*/
|
|
*/
|
|
|
public static function float($min = 0.0, $max = 999.0) {
|
|
public static function float($min = 0.0, $max = 999.0) {
|
|
|
$rand = rand(1, 358);
|
|
$rand = rand(1, 358);
|
|
@@ -32,6 +32,10 @@ class Random {
|
|
|
* Randomly return one of the values provided
|
|
* Randomly return one of the values provided
|
|
|
* careful: only works with numerical keys (0 based!)
|
|
* careful: only works with numerical keys (0 based!)
|
|
|
*
|
|
*
|
|
|
|
|
+ * @param $array
|
|
|
|
|
+ * @param int|null $minPosition
|
|
|
|
|
+ * @param int|null $maxPosition
|
|
|
|
|
+ * @param bool $integerKeys
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
public static function arrayValue($array, $minPosition = null, $maxPosition = null, $integerKeys = false) {
|
|
public static function arrayValue($array, $minPosition = null, $maxPosition = null, $integerKeys = false) {
|
|
@@ -54,6 +58,11 @@ class Random {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 1950-01-01 - 2050-12-31
|
|
* 1950-01-01 - 2050-12-31
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param int|null $min
|
|
|
|
|
+ * @param int|null $max
|
|
|
|
|
+ * @param bool|null $formatReturn
|
|
|
|
|
+ * @return int|null|string
|
|
|
*/
|
|
*/
|
|
|
public static function date($min = null, $max = null, $formatReturn = null) {
|
|
public static function date($min = null, $max = null, $formatReturn = null) {
|
|
|
if ($min === null && $max === null) {
|
|
if ($min === null && $max === null) {
|
|
@@ -80,6 +89,11 @@ class Random {
|
|
|
//TODO
|
|
//TODO
|
|
|
/**
|
|
/**
|
|
|
* 00:00:00 - 23:59:59
|
|
* 00:00:00 - 23:59:59
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param int|null $min
|
|
|
|
|
+ * @param int|null $max
|
|
|
|
|
+ * @param bool|null $formatReturn
|
|
|
|
|
+ * @return int
|
|
|
*/
|
|
*/
|
|
|
public static function time($min = null, $max = null, $formatReturn = null) {
|
|
public static function time($min = null, $max = null, $formatReturn = null) {
|
|
|
$res = 0;
|
|
$res = 0;
|
|
@@ -94,9 +108,9 @@ class Random {
|
|
|
/**
|
|
/**
|
|
|
* Returns a date of birth within the specified age range
|
|
* Returns a date of birth within the specified age range
|
|
|
*
|
|
*
|
|
|
- * @param (int) $min minimum age in years
|
|
|
|
|
- * @param (int) $max maximum age in years
|
|
|
|
|
- * @return (string) $dob a db (ISO) format datetime string
|
|
|
|
|
|
|
+ * @param int $min minimum age in years
|
|
|
|
|
+ * @param int $max maximum age in years
|
|
|
|
|
+ * @return string Dob a db (ISO) format datetime string
|
|
|
*/
|
|
*/
|
|
|
public static function dob($min = 18, $max = 100) {
|
|
public static function dob($min = 18, $max = 100) {
|
|
|
$dobYear = date('Y') - (static::int($min, $max));
|
|
$dobYear = date('Y') - (static::int($min, $max));
|
|
@@ -166,6 +180,10 @@ class Random {
|
|
|
* Few years ago i had written Joomla component AutoContent. That component generates new unique content and add it to Joomla site. In general, this is not good tool, because it does black SEO things. If search engine (ex. Google) finds that there is autogenerated text without sense then site can be banned
|
|
* Few years ago i had written Joomla component AutoContent. That component generates new unique content and add it to Joomla site. In general, this is not good tool, because it does black SEO things. If search engine (ex. Google) finds that there is autogenerated text without sense then site can be banned
|
|
|
*
|
|
*
|
|
|
* @link http://www.gelembjuk.com/index.php?option=com_content&view=article&id=60&catid=37:php&Itemid=56
|
|
* @link http://www.gelembjuk.com/index.php?option=com_content&view=article&id=60&catid=37:php&Itemid=56
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param array $sentences
|
|
|
|
|
+ * @param int $wordscount
|
|
|
|
|
+ * @return array
|
|
|
*/
|
|
*/
|
|
|
public static function sentences($sentences, $wordscount = 2) {
|
|
public static function sentences($sentences, $wordscount = 2) {
|
|
|
$hash = [];
|
|
$hash = [];
|
|
@@ -254,8 +272,8 @@ class Random {
|
|
|
* You can also create a custom type by providing the "pool" of characters
|
|
* You can also create a custom type by providing the "pool" of characters
|
|
|
* as the type.
|
|
* as the type.
|
|
|
*
|
|
*
|
|
|
- * @param string a type of pool, or a string of characters to use as the pool
|
|
|
|
|
- * @param int length of string to return
|
|
|
|
|
|
|
+ * @param string $type Type of pool, or a string of characters to use as the pool
|
|
|
|
|
+ * @param int $length of string to return
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
|
public static function generate($type = 'alnum', $length = 8) {
|
|
public static function generate($type = 'alnum', $length = 8) {
|