Skip to content

Commit

Permalink
add features for numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
rudak committed Nov 17, 2015
1 parent f12a8dd commit b9a6874
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Factory/FakeNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
class FakeNumber
{

public static function number($size = 5, $max = 999999)
{
return str_pad((int) rand(0, $max), $size, '0', STR_PAD_LEFT);
}

public static function phone()
{
return sprintf('%02d', rand(1, 5)) . self::formated() . self::formated() . self::formated() . self::formated();
Expand Down
30 changes: 30 additions & 0 deletions Factory/FakeText.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Created by PhpStorm.
* User: rudak
* Date: 17/11/2015
* Time: 19:08
*/

namespace Rudak\Bundle\FakeDataGenerator\Factory;


class FakeText
{

public static function char($size = 20, $numeric = false)
{
$str = '';
while (strlen($str) < $size) {
$str .= self::getCharacters($numeric);
}
return substr(str_shuffle($str), 0, $size);
}

private static function getCharacters($num = false)
{
$alpha = 'abcdefghijklmnopqrstuvwxz';
$numeric = '0123456789';
return $num ? $numeric . $alpha : $alpha;
}
}

0 comments on commit b9a6874

Please sign in to comment.