Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Faker\Provider\pl_PL;
4
 
5
class Company extends \Faker\Provider\Company
6
{
7
    protected static $formats = [
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 = ['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 = ['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
     *
33
     * @see http://pl.wikipedia.org/wiki/REGON
34
     *
35
     * @return string 9 digit number
36
     */
37
    public static function regon()
38
    {
39
        $weights = [8, 9, 2, 3, 4, 5, 6, 7];
40
        $regionNumber = self::numberBetween(0, 49) * 2 + 1;
41
        $result = [(int) ($regionNumber / 10), $regionNumber % 10];
42
 
43
        for ($i = 2, $size = count($weights); $i < $size; ++$i) {
44
            $result[$i] = static::randomDigit();
45
        }
46
        $checksum = 0;
47
 
48
        for ($i = 0, $size = count($result); $i < $size; ++$i) {
49
            $checksum += $weights[$i] * $result[$i];
50
        }
51
        $checksum %= 11;
52
 
53
        if ($checksum == 10) {
54
            $checksum = 0;
55
        }
56
        $result[] = $checksum;
57
 
58
        return implode('', $result);
59
    }
60
 
61
    /**
62
     * Register of the National Economy, local entity number
63
     *
64
     * @see http://pl.wikipedia.org/wiki/REGON
65
     *
66
     * @return string 14 digit number
67
     */
68
    public static function regonLocal()
69
    {
70
        $weights = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8];
71
        $result = str_split(static::regon());
72
 
73
        for ($i = count($result), $size = count($weights); $i < $size; ++$i) {
74
            $result[$i] = static::randomDigit();
75
        }
76
        $checksum = 0;
77
 
78
        for ($i = 0, $size = count($result); $i < $size; ++$i) {
79
            $checksum += $weights[$i] * $result[$i];
80
        }
81
        $checksum %= 11;
82
 
83
        if ($checksum == 10) {
84
            $checksum = 0;
85
        }
86
        $result[] = $checksum;
87
 
88
        return implode('', $result);
89
    }
90
}