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

Added Company and Internet Provider for de_AT #400

Merged
merged 3 commits into from
Aug 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Faker/Provider/de_AT/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Faker\Provider\de_AT;

class Company extends \Faker\Provider\Company
{
protected static $formats = array(
'{{lastName}} {{companySuffix}}',
'{{lastName}}',
);

protected static $companySuffix = array('AG', 'EWIV', 'Ges.m.b.H.', 'GmbH', 'KEG', 'KG', 'OEG', 'OG', 'OHG', 'SE');
}
45 changes: 45 additions & 0 deletions src/Faker/Provider/de_AT/Internet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Faker\Provider\de_AT;

class Internet extends \Faker\Provider\Internet
{
protected static $freeEmailDomain = array('aon.at', 'chello.at', 'gmail.com', 'gmx.at', 'univie.ac.at');
protected static $tld = array('at', 'co.at', 'com', 'net', 'org');

/**
* Converts German characters (Umlaute) to their ASCII representation
*
* @return string
*/
private static function toAscii($string)
{
$from = array('ä', 'Ä', 'ü', 'Ü', 'ö', 'Ö', 'ß');
$to = array('a', 'A', 'u', 'U', 'o', 'O', 'ss');

return str_replace($from, $to, $string);
}

/**
* @example 'jdoe'
*/
public function userName()
{
$format = static::randomElement(static::$userNameFormats);

return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
}

/**
* @example 'faber'
*/
public function domainWord()
{
$company = $this->generator->format('company');
$companyElements = explode(' ', $company);
$company = $companyElements[0];
$company = preg_replace('/\W/u', '', $company);

return static::toLower(static::toAscii($company));
}
}
32 changes: 32 additions & 0 deletions test/Faker/Provider/de_AT/InternetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Faker\Test\Provider\de_AT;

use Faker\Generator;
use Faker\Provider\de_AT\Person;
use Faker\Provider\de_AT\Internet;
use Faker\Provider\de_AT\Company;

class InternetTest extends \PHPUnit_Framework_TestCase
{

/**
* @var Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->addProvider(new Internet($faker));
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}

public function testEmailIsValid()
{
$email = $this->faker->email();
$this->assertNotFalse(filter_var($email, FILTER_VALIDATE_EMAIL));
}
}