Skip to content

Commit 713aab7

Browse files
committed
gdpr safe fake mobile and line line numbers
+ laravel lint cleanup
1 parent f3b7a9d commit 713aab7

18 files changed

+36
-44
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"require": {
2020
"php": "^8.1|^8.2",
21-
"brick/phonenumber": "^0.4.0",
21+
"brick/phonenumber": "^0.6.0",
2222
"byrokrat/banking": "^2.2",
2323
"laravel/framework": "^9.0|^10.0",
2424
"personnummer/personnummer": "^3.0.4",

src/Factories/FakeMobileNumber.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/**
66
* Swedish mobile number formats, while waiting for PR
77
*
8+
* @see https://fakerphp.github.io/locales/sv_SE/#fakerprovidersv_semobilenumber
89
* @see https://github.com/FakerPHP/Faker/pull/491
910
* @see https://www.pts.se/sv/bransch/telefoni/nummer-och-adressering/telefoninummerplanen/telefonnummers-struktur/
1011
*/
@@ -38,4 +39,10 @@ public static function make(bool $international = true): string
3839

3940
return self::numerify($val);
4041
}
42+
43+
/* Publishable GDPR Safe Swedish mobile number series */
44+
public static function gdprSafe(): string
45+
{
46+
return '070-1740' . fake()->numberBetween(605, 699);
47+
}
4148
}

src/Factories/FakePhoneNumber.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
/**
66
* Swedish phone number formats, both landline and mobile
7+
*
8+
* @see https://fakerphp.github.io/locales/sv_SE/#fakerprovidersv_sephonenumber
79
*/
810
class FakePhoneNumber extends \Faker\Provider\PhoneNumber
911
{
@@ -50,4 +52,15 @@ public static function make(bool $international = true): string
5052

5153
return self::numerify($val);
5254
}
55+
56+
/* Publishable GDPR Safe Swedish landline phone number series */
57+
public static function gdprSafe(): string
58+
{
59+
return fake()->randomElement([
60+
'031-3900' . fake()->numberBetween(600, 699),
61+
'040-6280' . fake()->numberBetween(400, 499),
62+
'08-46500' . fake()->numberBetween(400, 499),
63+
'0980-319' . fake()->numberBetween(200, 299),
64+
]);
65+
}
5366
}

src/Helpers/BusinessTypeFromNr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class BusinessTypeFromNr
1010
{
1111
/** returns 'business', 'individual' or 'undefined' */
12-
public static function make(string|int $nr): string
12+
public static function make(string | int $nr): string
1313
{
1414
if (filled($nr)) {
1515
if ((new PersonNummer)->passes(null, $nr)) {

src/LaravelRulesServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function bootingPackage(): void
5959
public function bootTranslations()
6060
{
6161
$name = $this->package->name;
62-
$langPath = resource_path('lang/'.'vendor/'.$name);
62+
$langPath = resource_path('lang/' . 'vendor/' . $name);
6363

6464
$this->publishes([
6565
$this->package->basePath('/../resources/lang') => $langPath,

src/RuleHelpers.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
class RuleHelpers
1010
{
1111
/**
12-
* @param string $vatID
13-
* @return string
14-
*
1512
* @deprecated use BusinessNameFromVatID::lookup(string $vatID)
1613
*/
1714
public static function getBusinessNameFromVatID(string $vatID): string
@@ -24,9 +21,6 @@ public static function getBusinessNameFromVatID(string $vatID): string
2421
}
2522

2623
/**
27-
* @param string $vatID
28-
* @return object
29-
*
3024
* @deprecated use VatDetailsFromVatID::lookup(string $vatID)
3125
*/
3226
public static function getVATDetailsFromVatID(string $vatID): object
@@ -39,6 +33,7 @@ public static function getVATDetailsFromVatID(string $vatID): object
3933
'name' => '',
4034
'address' => '',
4135
]);
36+
4237
try {
4338
return VatCalculator::getVATDetails($vatID) ?? $empty;
4439
} catch (\Exception) {
@@ -47,12 +42,9 @@ public static function getVATDetailsFromVatID(string $vatID): object
4742
}
4843

4944
/**
50-
* @param string|int $nr
51-
* @return string
52-
*
5345
* @deprecated use BusinessTypeFromNr::make(string|int $nr)
5446
*/
55-
public static function check_business_type(string|int $nr): string
47+
public static function check_business_type(string | int $nr): string
5648
{
5749
if (filled($nr)) {
5850
if ((new PersonNummer)->passes(null, $nr)) {

src/Rules/BankGiro.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class BankGiro implements Rule
1414
*
1515
* @param string $attribute
1616
* @param mixed $value
17-
* @return bool
1817
*/
1918
public function passes($attribute, $value): bool
2019
{
2120
if (blank($value)) {
2221
return false;
2322
}
23+
2424
try {
2525
return (new BankgiroFactory)->createAccount($value)->getBankName() === BankNames::BANK_BANKGIRO;
2626
} catch (Exception $e) {
@@ -30,8 +30,6 @@ public function passes($attribute, $value): bool
3030

3131
/**
3232
* Get the validation error message.
33-
*
34-
* @return string
3533
*/
3634
public function message(): string
3735
{

src/Rules/BankKonto.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class BankKonto implements Rule
1313
*
1414
* @param string $attribute
1515
* @param mixed $value
16-
* @return bool
1716
*/
1817
public function passes($attribute, $value): bool
1918
{
2019
if (blank($value)) {
2120
return false;
2221
}
22+
2323
try {
2424
return filled((new AccountFactory)->createAccount($value));
2525
} catch (Exception $e) {
@@ -29,8 +29,6 @@ public function passes($attribute, $value): bool
2929

3030
/**
3131
* Get the validation error message.
32-
*
33-
* @return string
3432
*/
3533
public function message(): string
3634
{

src/Rules/FixedLineNumber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ class FixedLineNumber implements Rule
1515
/**
1616
* @param string $attribute
1717
* @param mixed $value
18-
* @return bool
1918
*/
2019
public function passes($attribute, $value): bool
2120
{
2221
if (blank($value)) {
2322
return false;
2423
}
24+
2525
try {
2626
if (! str_starts_with($value, '+')) {
27-
$value = '+'.$value;
27+
$value = '+' . $value;
2828
}
2929
$number = Validator::parse((string) $value);
3030

src/Rules/Latitude.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public function passes($attribute, $value): bool
2020

2121
/**
2222
* Get the validation error message.
23-
*
24-
* @return string
2523
*/
2624
public function message(): string
2725
{

0 commit comments

Comments
 (0)