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

Added Address and Company [fa_IR] #1160

Merged
merged 4 commits into from
Apr 7, 2017
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
21 changes: 21 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,27 @@ echo $faker->vat; // "A35864370"
echo $faker->dni; // '83367512'
```

### `Faker\Provider\fa_IR\Address`

```php
<?php

// Generates a random building name
echo $faker->building; // "ساختمان آفتاب"

// Returns a random city name
echo $faker->city // "استان زنجان"
```

### `Faker\Provider\fa_IR\Company`

```php
<?php

// Generates a random contract type
echo $faker->contract; // "رسمی"
```

### `Faker\Provider\fi_FI\Payment`

```php
Expand Down
100 changes: 100 additions & 0 deletions src/Faker/Provider/fa_IR/Address.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

namespace Faker\Provider\fa_IR;

class Address extends \Faker\Provider\Address
{
protected static $cityPrefix = array('استان');
protected static $streetPrefix = array('خیابان');
protected static $buildingNamePrefix = array('ساختمان');
protected static $buildingNumberPrefix = array('پلاک', 'قطعه');
protected static $postcodePrefix = array('کد پستی');

protected static $cityName = array(
"آذربایجان شرقی", "آذربایجان غربی", "اردبیل", "اصفهان", "البرز", "ایلام", "بوشهر",
"تهران", "خراسان جنوبی", "خراسان رضوی", "خراسان شمالی", "خوزستان", "زنجان", "سمنان",
"سیستان و بلوچستان", "فارس", "قزوین", "قم", "لرستان", "مازندران", "مرکزی", "هرمزگان",
"همدان", "چهارمحال و بختیاری", "کردستان", "کرمان", "کرمانشاه", "کهگیلویه و بویراحمد",
"گلستان", "گیلان", "یزد"
);

protected static $cityFormats = array(
'{{cityName}}',
'{{cityPrefix}} {{cityName}}',
);
protected static $streetNameFormats = array(
'{{streetPrefix}} {{lastName}}'
);
protected static $streetAddressFormats = array(
'{{streetName}} {{building}}'
);
protected static $addressFormats = array(
'{{city}} {{streetAddress}} {{postcodePrefix}} {{postcode}}',
'{{city}} {{streetAddress}}',
);
protected static $buildingFormat = array(
'{{buildingNamePrefix}} {{firstName}} {{buildingNumberPrefix}} {{buildingNumber}}',
'{{buildingNamePrefix}} {{firstName}}',
);

protected static $postcode = array('##########');
protected static $country = array('ایران');

/**
* @example 'استان'
*/
public static function cityPrefix()
{
return static::randomElement(static::$cityPrefix);
}

/**
* @example 'زنجان'
*/
public static function cityName()
{
return static::randomElement(static::$cityName);
}

/**
* @example 'خیابان'
*/
public static function streetPrefix()
{
return static::randomElement(static::$streetPrefix);
}

/**
* @example 'ساختمان'
*/
public static function buildingNamePrefix()
{
return static::randomElement(static::$buildingNamePrefix);
}

/**
* @example 'پلاک'
*/
public static function buildingNumberPrefix()
{
return static::randomElement(static::$buildingNumberPrefix);
}

/**
* @example 'ساختمان آفتاب پلاک 24'
*/
public function building()
{
$format = static::randomElement(static::$buildingFormat);

return $this->generator->parse($format);
}

/**
* @example 'کد پستی'
*/
public static function postcodePrefix()
{
return static::randomElement(static::$postcodePrefix);
}
}
57 changes: 57 additions & 0 deletions src/Faker/Provider/fa_IR/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Faker\Provider\fa_IR;

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

protected static $companyPrefix = array(
'شرکت', 'موسسه', 'سازمان', 'بنیاد'
);

protected static $companyField = array(
'فناوری اطلاعات', 'راه و ساختمان', 'توسعه معادن', 'استخراج و اکتشاف',
'سرمایه گذاری', 'نساجی', 'کاریابی', 'تجهیزات اداری', 'تولیدی', 'فولاد'
);

protected static $contract = array(
'رسمی', 'پیمانی', 'تمام وقت', 'پاره وقت', 'پروژه ای', 'ساعتی',
);

/**
* @example 'شرکت'
* @return string
*/
public static function companyPrefix()
{
return static::randomElement(static::$companyPrefix);
}

/**
* @example 'سرمایه گذاری'
* @return string
*/
public static function companyField()
{
return static::randomElement(static::$companyField);
}

/**
* @example 'تمام وقت'
* @return string
*/
public function contract()
{
return static::randomElement(static::$contract);
}
}
6 changes: 3 additions & 3 deletions src/Faker/Provider/fa_IR/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
* @link https://fa.wikipedia.org/wiki/%D8%B4%D9%85%D8%A7%D8%B1%D9%87%E2%80%8C%D9%87%D8%A7%DB%8C_%D8%AA%D9%84%D9%81%D9%86_%D8%AF%D8%B1_%D8%A7%DB%8C%D8%B1%D8%A7%D9%86#.D8.AA.D9.84.D9.81.D9.86.E2.80.8C.D9.87.D8.A7.DB.8C_.D9.87.D9.85.D8.B1.D8.A7.D9.87
*/
protected static $formats = array(
'021#######',
'026#######',
'031#######',
'021########',
'026########',
'031########',
);
protected static $mobileNumberPrefixes = array(
'0910#######',//mci
Expand Down