Skip to content

Commit

Permalink
Simplified Generator method names
Browse files Browse the repository at this point in the history
  • Loading branch information
rplansky committed Apr 5, 2015
1 parent f7cb73d commit e77547f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $validator->isValid('57234651187928922');

```php
$generator = new Plansky\CreditCard\Generator();
$generator->generate();
$generator->single();
// 99119662018492824
```

Expand All @@ -53,7 +53,7 @@ You can generate a random number using a brand prefix.

```php
$generator = new Plansky\CreditCard\Generator();
$generator->generate(301); // Generates a DINERS number
$generator->single(301); // Generates a DINERS number
// 30192056094873699
```

Expand All @@ -63,7 +63,7 @@ Some brands have different number length.

```php
$generator = new Plansky\CreditCard\Generator();
$generator->generate(347, 15); // Generates an AMEX number
$generator->single(347, 15); // Generates an AMEX number
// 3479966030620031
```

Expand All @@ -75,7 +75,7 @@ numbers at once

```php
$generator = new Plansky\CreditCard\Generator();
$generator->generateLot(10, 347, 15); // Generates 10 AMEX numbers
$generator->lot(10, 347, 15); // Generates 10 AMEX numbers
// array(
// 0 => '3479132843454361',
// 1 => '3479587605801416',
Expand All @@ -94,7 +94,7 @@ $generator->generateLot(10, 347, 15); // Generates 10 AMEX numbers

#### ccgenerator

You can use same parameters of `Generator::generateLot()` method, plus,
You can use same parameters of `Generator::lot()` method, plus,
`separator` parameter to render your output

```shell
Expand Down
2 changes: 1 addition & 1 deletion bin/ccgenerator
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $parameters = getopt(
);

echo implode(
(new Plansky\CreditCard\Generator())->generateLot(
(new Plansky\CreditCard\Generator())->lot(
isset($parameters['amount']) ? $parameters['amount'] : 1,
isset($parameters['prefix']) ? $parameters['prefix'] : null,
isset($parameters['length']) ? $parameters['length'] : 16
Expand Down
6 changes: 3 additions & 3 deletions src/Plansky/CreditCard/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Generator
*
* @return string
*/
public function generate($prefix = null, $length = 16)
public function single($prefix = null, $length = 16)
{
$number = $prefix . $this->getRand($length - strlen($prefix));

Expand All @@ -33,11 +33,11 @@ public function generate($prefix = null, $length = 16)
*
* @return integer[]
*/
public function generateLot($amount, $prefix = null, $length = 16)
public function lot($amount, $prefix = null, $length = 16)
{
$numbers = [];
for ($index = 1; $index <= $amount; $index++) {
$numbers[] = $this->generate($prefix, $length);
$numbers[] = $this->single($prefix, $length);
}

return $numbers;
Expand Down

0 comments on commit e77547f

Please sign in to comment.