1 | <?php namespace Propaganistas\LaravelPhone\Rules; |
||
7 | class Phone |
||
8 | { |
||
9 | /** |
||
10 | * The provided phone countries. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $countries = []; |
||
15 | |||
16 | /** |
||
17 | * The input field name to check for a country value. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $countryField; |
||
22 | |||
23 | /** |
||
24 | * The provided phone types. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $types = []; |
||
29 | |||
30 | /** |
||
31 | * Whether the number's country should be auto-detected. |
||
32 | * |
||
33 | * @var bool |
||
34 | */ |
||
35 | protected $detect = false; |
||
36 | |||
37 | /** |
||
38 | * Whether to allow lenient checks (i.e. landline numbers without area codes). |
||
39 | * |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $lenient = false; |
||
43 | |||
44 | /** |
||
45 | * Set the phone countries. |
||
46 | * |
||
47 | * @param string|array $country |
||
48 | * @return $this |
||
49 | */ |
||
50 | 3 | public function country($country) |
|
51 | { |
||
52 | 3 | $countries = is_array($country) ? $country : func_get_args(); |
|
53 | |||
54 | 3 | $this->countries = array_merge($this->countries, $countries); |
|
55 | |||
56 | 3 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Set the country input field. |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @return $this |
||
64 | */ |
||
65 | 3 | public function countryField($name) |
|
71 | |||
72 | /** |
||
73 | * Set the phone types. |
||
74 | * |
||
75 | * @param string|array $type |
||
76 | * @return $this |
||
77 | */ |
||
78 | 3 | public function type($type) |
|
86 | |||
87 | /** |
||
88 | * Shortcut method for mobile type restriction. |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 3 | public function mobile() |
|
98 | |||
99 | /** |
||
100 | * Shortcut method for fixed line type restriction. |
||
101 | * |
||
102 | * @return $this |
||
103 | */ |
||
104 | 3 | public function fixedLine() |
|
110 | |||
111 | /** |
||
112 | * Enable automatic country detection. |
||
113 | * |
||
114 | * @return $this |
||
115 | */ |
||
116 | 3 | public function detect() |
|
122 | |||
123 | /** |
||
124 | * Enable lenient number checking. |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | 3 | public function lenient() |
|
134 | |||
135 | /** |
||
136 | * Convert the rule to a validation string. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 3 | public function __toString() |
|
152 | } |