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;
4
 
5
class Address extends Base
6
{
7
    protected static $citySuffix = ['Ville'];
8
    protected static $streetSuffix = ['Street'];
9
    protected static $cityFormats = [
10
        '{{firstName}}{{citySuffix}}',
11
    ];
12
    protected static $streetNameFormats = [
13
        '{{lastName}} {{streetSuffix}}',
14
    ];
15
    protected static $streetAddressFormats = [
16
        '{{buildingNumber}} {{streetName}}',
17
    ];
18
    protected static $addressFormats = [
19
        '{{streetAddress}} {{postcode}} {{city}}',
20
    ];
21
 
22
    protected static $buildingNumber = ['%#'];
23
    protected static $postcode = ['#####'];
24
    protected static $country = [];
25
 
26
    /**
27
     * @example 'town'
28
     *
29
     * @return string
30
     */
31
    public static function citySuffix()
32
    {
33
        return static::randomElement(static::$citySuffix);
34
    }
35
 
36
    /**
37
     * @example 'Avenue'
38
     *
39
     * @return string
40
     */
41
    public static function streetSuffix()
42
    {
43
        return static::randomElement(static::$streetSuffix);
44
    }
45
 
46
    /**
47
     * @example '791'
48
     *
49
     * @return string
50
     */
51
    public static function buildingNumber()
52
    {
53
        return static::numerify(static::randomElement(static::$buildingNumber));
54
    }
55
 
56
    /**
57
     * @example 'Sashabury'
58
     *
59
     * @return string
60
     */
61
    public function city()
62
    {
63
        $format = static::randomElement(static::$cityFormats);
64
 
65
        return $this->generator->parse($format);
66
    }
67
 
68
    /**
69
     * @example 'Crist Parks'
70
     *
71
     * @return string
72
     */
73
    public function streetName()
74
    {
75
        $format = static::randomElement(static::$streetNameFormats);
76
 
77
        return $this->generator->parse($format);
78
    }
79
 
80
    /**
81
     * @example '791 Crist Parks'
82
     *
83
     * @return string
84
     */
85
    public function streetAddress()
86
    {
87
        $format = static::randomElement(static::$streetAddressFormats);
88
 
89
        return $this->generator->parse($format);
90
    }
91
 
92
    /**
93
     * @example 86039-9874
94
     *
95
     * @return string
96
     */
97
    public static function postcode()
98
    {
99
        return static::toUpper(static::bothify(static::randomElement(static::$postcode)));
100
    }
101
 
102
    /**
103
     * @example '791 Crist Parks, Sashabury, IL 86039-9874'
104
     *
105
     * @return string
106
     */
107
    public function address()
108
    {
109
        $format = static::randomElement(static::$addressFormats);
110
 
111
        return $this->generator->parse($format);
112
    }
113
 
114
    /**
115
     * @example 'Japan'
116
     *
117
     * @return string
118
     */
119
    public static function country()
120
    {
121
        return static::randomElement(static::$country);
122
    }
123
 
124
    /**
125
     * Uses signed degrees format (returns a float number between -90 and 90)
126
     *
127
     * @example '77.147489'
128
     *
129
     * @param float|int $min
130
     * @param float|int $max
131
     *
132
     * @return float
133
     */
134
    public static function latitude($min = -90, $max = 90)
135
    {
136
        return static::randomFloat(6, $min, $max);
137
    }
138
 
139
    /**
140
     * Uses signed degrees format (returns a float number between -180 and 180)
141
     *
142
     * @example '86.211205'
143
     *
144
     * @param float|int $min
145
     * @param float|int $max
146
     *
147
     * @return float
148
     */
149
    public static function longitude($min = -180, $max = 180)
150
    {
151
        return static::randomFloat(6, $min, $max);
152
    }
153
 
154
    /**
155
     * @example array('77.147489', '86.211205')
156
     *
157
     * @return float[]
158
     */
159
    public static function localCoordinates()
160
    {
161
        return [
162
            'latitude' => static::latitude(),
163
            'longitude' => static::longitude(),
164
        ];
165
    }
166
}