Address.php
5 years ago
Company.php
5 years ago
Internet.php
5 years ago
Payment.php
5 years ago
Person.php
5 years ago
PhoneNumber.php
5 years ago
Text.php
5 years ago
Company.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Faker\Provider\pl_PL; |
| 4 | |
| 5 | class Company extends \Faker\Provider\Company |
| 6 | { |
| 7 | protected static $formats = array( |
| 8 | '{{lastName}}', |
| 9 | '{{lastName}}', |
| 10 | '{{lastName}} {{companySuffix}}', |
| 11 | '{{lastName}} {{companySuffix}}', |
| 12 | '{{lastName}} {{companySuffix}}', |
| 13 | '{{lastName}} {{companySuffix}}', |
| 14 | '{{companyPrefix}} {{lastName}}', |
| 15 | '{{lastName}}-{{lastName}}', |
| 16 | ); |
| 17 | |
| 18 | protected static $companySuffix = array('S.A.', 'i syn', 'sp. z o.o.', 'sp. j.', 'sp. p.', 'sp. k.', 'S.K.A', 's. c.', 'P.P.O.F'); |
| 19 | |
| 20 | protected static $companyPrefix = array('Grupa', 'Fundacja', 'Stowarzyszenie', 'Spółdzielnia'); |
| 21 | |
| 22 | /** |
| 23 | * @example 'Grupa' |
| 24 | */ |
| 25 | public static function companyPrefix() |
| 26 | { |
| 27 | return static::randomElement(static::$companyPrefix); |
| 28 | } |
| 29 | |
| 30 | /* |
| 31 | * Register of the National Economy |
| 32 | * @link http://pl.wikipedia.org/wiki/REGON |
| 33 | * @return 9 digit number |
| 34 | */ |
| 35 | public static function regon() |
| 36 | { |
| 37 | $weights = array(8, 9, 2, 3, 4, 5, 6, 7); |
| 38 | $regionNumber = static::numberBetween(0, 49) * 2 + 1; |
| 39 | $result = array((int) ($regionNumber / 10), $regionNumber % 10); |
| 40 | for ($i = 2, $size = count($weights); $i < $size; $i++) { |
| 41 | $result[$i] = static::randomDigit(); |
| 42 | } |
| 43 | $checksum = 0; |
| 44 | for ($i = 0, $size = count($result); $i < $size; $i++) { |
| 45 | $checksum += $weights[$i] * $result[$i]; |
| 46 | } |
| 47 | $checksum %= 11; |
| 48 | if ($checksum == 10) { |
| 49 | $checksum = 0; |
| 50 | } |
| 51 | $result[] = $checksum; |
| 52 | |
| 53 | return implode('', $result); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Register of the National Economy, local entity number |
| 58 | * @link http://pl.wikipedia.org/wiki/REGON |
| 59 | * @return 14 digit number |
| 60 | */ |
| 61 | public static function regonLocal() |
| 62 | { |
| 63 | $weights = array(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8); |
| 64 | $result = str_split(static::regon()); |
| 65 | for ($i = count($result), $size = count($weights); $i < $size; $i++) { |
| 66 | $result[$i] = static::randomDigit(); |
| 67 | } |
| 68 | $checksum = 0; |
| 69 | for ($i = 0, $size = count($result); $i < $size; $i++) { |
| 70 | $checksum += $weights[$i] * $result[$i]; |
| 71 | } |
| 72 | $checksum %= 11; |
| 73 | if ($checksum == 10) { |
| 74 | $checksum = 0; |
| 75 | } |
| 76 | $result[] = $checksum; |
| 77 | |
| 78 | return implode('', $result); |
| 79 | } |
| 80 | } |
| 81 |