Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1392 from ffiguereo/master
Browse files Browse the repository at this point in the history
Add licenceCode method in the to es_ES person provider
  • Loading branch information
fzaninotto authored Dec 30, 2017
2 parents 1bb3d39 + 43383ce commit 044c313
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ echo $faker->mobileNumber; // 082 123 5555

// Generates a Documento Nacional de Identidad (DNI) number
echo $faker->dni; // '77446565E'

// Generates a random valid licence code
echo $faker->licenceCode; // B
```

### `Faker\Provider\es_ES\Payment`
Expand Down
12 changes: 12 additions & 0 deletions src/Faker/Provider/es_ES/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Person extends \Faker\Provider\Person

private static $suffix = array('Hijo', 'Segundo', 'Tercero');

protected static $licenceCodes = array('AM', 'A1', 'A2', 'A','B', 'B+E', 'C1', 'C1+E', 'C', 'C+E', 'D1', 'D1+E', 'D', 'D+E');

/**
* @example 'Hijo'
*/
Expand All @@ -85,4 +87,14 @@ public static function dni()

return $number . $letter;
}

/**
* @see https://sede.dgt.gob.es/es/tramites-y-multas/permiso-de-conduccion/obtencion-permiso-licencia-conduccion/clases-permiso-conduccion-edad.shtml
*
* @return string
*/
public function licenceCode()
{
return static::randomElement(static::$licenceCodes);
}
}
7 changes: 7 additions & 0 deletions test/Faker/Provider/es_ES/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public function isValidDNI($string)

return strtoupper($letter) === $map[((int) $number) % 23];
}

public function testLicenceCode()
{
$validLicenceCodes = array('AM', 'A1', 'A2', 'A','B', 'B+E', 'C1', 'C1+E', 'C', 'C+E', 'D1', 'D1+E', 'D', 'D+E');

$this->assertContains($this->faker->licenceCode, $validLicenceCodes);
}
}

0 comments on commit 044c313

Please sign in to comment.