Skip to content

Commit f9a7a3c

Browse files
committed
PhpCs fix
1 parent fc6ba92 commit f9a7a3c

File tree

10 files changed

+94
-57
lines changed

10 files changed

+94
-57
lines changed

src/Domain/Configuration/Service/LegacyUrlBuilder.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ public function withUid(string $baseUrl, string $uid): string
1717

1818
$parts['query'] = http_build_query($query);
1919

20-
// rebuild url
21-
$scheme = $parts['scheme'] ?? 'https';
22-
$host = $parts['host'] ?? '';
23-
$port = isset($parts['port']) ? ':'.$parts['port'] : '';
24-
$path = $parts['path'] ?? '';
25-
$queryStr = $parts['query'] ? '?'.$parts['query'] : '';
26-
$frag = isset($parts['fragment']) ? '#'.$parts['fragment'] : '';
20+
$scheme = $parts['scheme'] ?? 'https';
21+
$host = $parts['host'] ?? '';
22+
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
23+
$path = $parts['path'] ?? '';
24+
$queryStr = $parts['query'] ? '?' . $parts['query'] : '';
25+
$frag = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
2726

28-
return "{$scheme}://{$host}{$port}{$path}{$queryStr}{$frag}";
27+
return $scheme . '://' . $host . $port . $path . $queryStr . $frag;
2928
}
3029
}

src/Domain/Configuration/Service/PlaceholderResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public function register(string $token, callable $provider): void
1717

1818
public function resolve(?string $input): ?string
1919
{
20-
if ($input === null || $input === '') return $input;
20+
if ($input === null || $input === '') {
21+
return $input;
22+
}
2123

2224
// Replace [TOKEN] (case-insensitive)
2325
return preg_replace_callback('/\[(\w+)\]/i', function ($map) {

src/Domain/Configuration/Service/Provider/ConfigProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ public function __construct(
2222
) {
2323
}
2424

25-
/** @SuppressWarnings(PHPMD.StaticAccess) */
25+
/**
26+
* @SuppressWarnings(PHPMD.StaticAccess)
27+
* @throws InvalidArgumentException
28+
*/
2629
public function isEnabled(ConfigOption $key): bool
2730
{
2831
if (!in_array($key, $this->booleanValues)) {
@@ -40,6 +43,7 @@ public function isEnabled(ConfigOption $key): bool
4043
/**
4144
* Get configuration value by its key, from settings or default configs or default value (if provided)
4245
* @SuppressWarnings(PHPMD.StaticAccess)
46+
* @throws InvalidArgumentException
4347
*/
4448
public function getValue(ConfigOption $key): ?string
4549
{

src/Domain/Configuration/Service/Provider/DefaultConfigProvider.php

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Symfony\Contracts\Translation\TranslatorInterface;
88

9+
// phpcs:disable Generic.Files.LineLength
910
/** @SuppressWarnings(PHPMD.StaticAccess) */
1011
class DefaultConfigProvider
1112
{
@@ -87,7 +88,9 @@ private static function init(): void
8788
],
8889
'admin_addresses' => [
8990
'value' => '',
90-
'description' => self::$translator->trans('List of email addresses to CC in system messages (separate by commas)'),
91+
'description' => self::$translator->trans(
92+
'List of email addresses to CC in system messages (separate by commas)'
93+
),
9194
'type' => 'emaillist',
9295
'allowempty' => true,
9396
'category' => 'reporting',
@@ -121,7 +124,7 @@ private static function init(): void
121124
'category' => 'campaign',
122125
],
123126
'analytic_tracker' => [
124-
'values' => array('google' => 'Google Analytics', 'matomo' => 'Matomo'),
127+
'values' => ['google' => 'Google Analytics', 'matomo' => 'Matomo'],
125128
'value' => 'google',
126129
'description' => self::$translator->trans('Analytics tracking code to add to campaign URLs'),
127130
'type' => 'select',
@@ -130,7 +133,9 @@ private static function init(): void
130133
],
131134
'report_address' => [
132135
'value' => 'listreports@[DOMAIN]',
133-
'description' => self::$translator->trans('Who gets the reports (email address, separate multiple emails with a comma)'),
136+
'description' => self::$translator->trans(
137+
'Who gets the reports (email address, separate multiple emails with a comma)'
138+
),
134139
'type' => 'emaillist',
135140
'allowempty' => true,
136141
'category' => 'reporting',
@@ -221,54 +226,54 @@ private static function init(): void
221226
'description' => self::$translator->trans('The HTML wrapper template for system messages'),
222227
'type' => 'integer',
223228
'min' => 0,
224-
'max' => 999, // or max(id) from template
229+
'max' => 999,
225230
'allowempty' => true,
226231
'category' => 'transactional',
227232
],
228233
'subscribeurl' => [
229-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=subscribe",
234+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=subscribe',
230235
'description' => self::$translator->trans('URL where subscribers can sign up'),
231236
'type' => 'url',
232237
'allowempty' => 0,
233238
'category' => 'subscription',
234239
],
235240
'unsubscribeurl' => [
236-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=unsubscribe",
241+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=unsubscribe',
237242
'description' => self::$translator->trans('URL where subscribers can unsubscribe'),
238243
'type' => 'url',
239244
'allowempty' => 0,
240245
'category' => 'subscription',
241246
],
242247
'blacklisturl' => [
243-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=donotsend",
248+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=donotsend',
244249
'description' => self::$translator->trans('URL where unknown users can unsubscribe (do-not-send-list)'),
245250
'type' => 'url',
246251
'allowempty' => 0,
247252
'category' => 'subscription',
248253
],
249254
'confirmationurl' => [
250-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=confirm",
255+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=confirm',
251256
'description' => self::$translator->trans('URL where subscribers have to confirm their subscription'),
252257
'type' => 'text',
253258
'allowempty' => 0,
254259
'category' => 'subscription',
255260
],
256261
'preferencesurl' => [
257-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=preferences",
262+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=preferences',
258263
'description' => self::$translator->trans('URL where subscribers can update their details'),
259264
'type' => 'text',
260265
'allowempty' => 0,
261266
'category' => 'subscription',
262267
],
263268
'forwardurl' => [
264-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=forward",
269+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=forward',
265270
'description' => self::$translator->trans('URL for forwarding messages'),
266271
'type' => 'text',
267272
'allowempty' => 0,
268273
'category' => 'subscription',
269274
],
270275
'vcardurl' => [
271-
'value' => $publicSchema."://[WEBSITE]$pageRoot/?p=vcard",
276+
'value' => $publicSchema . '://[WEBSITE]' . $pageRoot . '/?p=vcard',
272277
'description' => self::$translator->trans('URL for downloading vcf card'),
273278
'type' => 'text',
274279
'allowempty' => 0,
@@ -283,15 +288,16 @@ private static function init(): void
283288
],
284289
'subscribesubject' => [
285290
'value' => self::$translator->trans('Request for confirmation'),
286-
'description' => self::$translator->trans('Subject of the message subscribers receive when they sign up'),
291+
'description' => self::$translator->trans(
292+
'Subject of the message subscribers receive when they sign up'
293+
),
287294
'infoicon' => true,
288295
'type' => 'text',
289296
'allowempty' => 0,
290297
'category' => 'transactional',
291298
],
292299
'subscribemessage' => [
293-
'value' =>
294-
' You have been subscribed to the following newsletters:
300+
'value' => ' You have been subscribed to the following newsletters:
295301
296302
[LISTS]
297303
@@ -317,14 +323,15 @@ private static function init(): void
317323
],
318324
'unsubscribesubject' => [
319325
'value' => self::$translator->trans('Goodbye from our Newsletter'),
320-
'description' => self::$translator->trans('Subject of the message subscribers receive when they unsubscribe'),
326+
'description' => self::$translator->trans(
327+
'Subject of the message subscribers receive when they unsubscribe'
328+
),
321329
'type' => 'text',
322330
'allowempty' => 0,
323331
'category' => 'transactional',
324332
],
325333
'unsubscribemessage' => [
326-
'value' =>
327-
'Goodbye from our Newsletter, sorry to see you go.
334+
'value' => 'Goodbye from our Newsletter, sorry to see you go.
328335
329336
You have been unsubscribed from our newsletters.
330337
@@ -343,14 +350,15 @@ private static function init(): void
343350
],
344351
'confirmationsubject' => [
345352
'value' => self::$translator->trans('Welcome to our Newsletter'),
346-
'description' => self::$translator->trans('Subject of the message subscribers receive after confirming their email address'),
353+
'description' => self::$translator->trans(
354+
'Subject of the message subscribers receive after confirming their email address'
355+
),
347356
'type' => 'text',
348357
'allowempty' => 0,
349358
'category' => 'transactional',
350359
],
351360
'confirmationmessage' => [
352-
'value' =>
353-
'Welcome to our Newsletter
361+
'value' => 'Welcome to our Newsletter
354362
355363
Please keep this message for later reference.
356364
@@ -362,14 +370,18 @@ private static function init(): void
362370
363371
Thank you'
364372
,
365-
'description' => self::$translator->trans('Message subscribers receive after confirming their email address'),
373+
'description' => self::$translator->trans(
374+
'Message subscribers receive after confirming their email address'
375+
),
366376
'type' => 'textarea',
367377
'allowempty' => 0,
368378
'category' => 'transactional',
369379
],
370380
'updatesubject' => [
371381
'value' => self::$translator->trans('[notify] Change of List-Membership details'),
372-
'description' => self::$translator->trans('Subject of the message subscribers receive when they have changed their details'),
382+
'description' => self::$translator->trans(
383+
'Subject of the message subscribers receive when they have changed their details'
384+
),
373385
'type' => 'text',
374386
'allowempty' => 0,
375387
'category' => 'transactional',
@@ -379,8 +391,7 @@ private static function init(): void
379391
// confirmationinfo is replaced by one of the options below
380392
// userdata is replaced by the information in the database
381393
'updatemessage' => [
382-
'value' =>
383-
'This message is to inform you of a change of your details on our newsletter database
394+
'value' => 'This message is to inform you of a change of your details on our newsletter database
384395
385396
You are currently member of the following newsletters:
386397
@@ -398,7 +409,9 @@ private static function init(): void
398409
399410
Thank you'
400411
,
401-
'description' => self::$translator->trans('Message subscribers receive when they have changed their details'),
412+
'description' => self::$translator->trans(
413+
'Message subscribers receive when they have changed their details'
414+
),
402415
'type' => 'textarea',
403416
'allowempty' => 0,
404417
'category' => 'transactional',
@@ -423,8 +436,7 @@ private static function init(): void
423436
// message, in case the email is sent to their old email address and they have changed
424437
// their email address
425438
'emailchanged_text_oldaddress' => [
426-
'value' =>
427-
'Please Note: when updating your details, your email address has changed.
439+
'value' => 'Please Note: when updating your details, your email address has changed.
428440
429441
A message has been sent to your new email address with a URL
430442
to confirm this change. Please visit this website to activate
@@ -437,7 +449,9 @@ private static function init(): void
437449
],
438450
'personallocation_subject' => [
439451
'value' => self::$translator->trans('Your personal location'),
440-
'description' => self::$translator->trans('Subject of message when subscribers request their personal location'),
452+
'description' => self::$translator->trans(
453+
'Subject of message when subscribers request their personal location'
454+
),
441455
'type' => 'text',
442456
'allowempty' => 0,
443457
'category' => 'transactional',
@@ -473,8 +487,7 @@ private static function init(): void
473487
'category' => 'campaign',
474488
],
475489
'personallocation_message' => [
476-
'value' =>
477-
'You have requested your personal location to update your details from our website.
490+
'value' => 'You have requested your personal location to update your details from our website.
478491
The location is below. Please make sure that you use the full line as mentioned below.
479492
Sometimes email programmes can wrap the line into multiple lines.
480493
@@ -490,7 +503,9 @@ private static function init(): void
490503
],
491504
'remoteurl_append' => [
492505
'value' => '',
493-
'description' => self::$translator->trans('String to always append to remote URL when using send-a-webpage'),
506+
'description' => self::$translator->trans(
507+
'String to always append to remote URL when using send-a-webpage'
508+
),
494509
'type' => 'text',
495510
'allowempty' => true,
496511
'category' => 'campaign',

src/Domain/Configuration/Service/UserPersonalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public function __construct(
2020
private readonly SubscriberRepository $subscriberRepository,
2121
private readonly SubscriberAttributeValueRepository $attributesRepository,
2222
private readonly AttributeValueResolver $attributeValueResolver
23-
) {}
23+
) {
24+
}
2425

2526
public function personalize(string $value, string $email): string
2627
{

src/Domain/Subscription/Repository/DynamicListAttrRepository.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@
88
use Doctrine\DBAL\Connection;
99
use Doctrine\DBAL\Exception;
1010
use InvalidArgumentException;
11+
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
1112

1213
class DynamicListAttrRepository
1314
{
1415
public function __construct(
1516
private readonly Connection $connection,
1617
private readonly string $prefix = 'phplist_'
17-
) {}
18+
) {
19+
}
1820

1921
/**
2022
* @return list<string>
21-
* @throws Exception
23+
* @throws InvalidArgumentException
2224
*/
2325
public function fetchOptionNames(string $listTable, array $ids): array
2426
{
25-
if (empty($ids)) return [];
27+
if (empty($ids)) {
28+
return [];
29+
}
2630

2731
if (!preg_match('/^[A-Za-z0-9_]+$/', $listTable)) {
2832
throw new InvalidArgumentException('Invalid list table');

src/Domain/Subscription/Service/Provider/CheckboxGroupValueProvider.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
class CheckboxGroupValueProvider implements AttributeValueProvider
1212
{
13-
public function __construct(private DynamicListAttrRepository $repo) {}
13+
public function __construct(private readonly DynamicListAttrRepository $repo)
14+
{
15+
}
1416

1517
public function supports(SubscriberAttributeDefinition $attribute): bool
1618
{
17-
// todo: check what real types exist in the database
19+
// phpcs:ignore Generic.Commenting.Todo
20+
// @todo: check what real types exist in the database
1821
return $attribute->getType() === 'checkboxgroup';
1922
}
2023

@@ -25,12 +28,14 @@ public function getValue(SubscriberAttributeDefinition $attribute, SubscriberAtt
2528
return '';
2629
}
2730

28-
$ids = array_values(array_filter(array_map(
29-
fn($value) => ($index = (int)trim($value)) > 0 ? $index : null,
30-
explode(',', $csv)
31-
)));
31+
$ids = array_values(array_filter(array_map(function ($value) {
32+
$index = (int) trim($value);
33+
return $index > 0 ? $index : null;
34+
}, explode(',', $csv))));
3235

33-
if (empty($ids) || !$attribute->getTableName()) return '';
36+
if (empty($ids) || !$attribute->getTableName()) {
37+
return '';
38+
}
3439

3540
$names = $this->repo->fetchOptionNames($attribute->getTableName(), $ids);
3641

src/Domain/Subscription/Service/Provider/SelectOrRadioValueProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
class SelectOrRadioValueProvider implements AttributeValueProvider
1212
{
13-
public function __construct(private readonly DynamicListAttrRepository $repo) {}
13+
public function __construct(private readonly DynamicListAttrRepository $repo)
14+
{
15+
}
1416

1517
public function supports(SubscriberAttributeDefinition $attribute): bool
1618
{
@@ -19,7 +21,9 @@ public function supports(SubscriberAttributeDefinition $attribute): bool
1921

2022
public function getValue(SubscriberAttributeDefinition $attribute, SubscriberAttributeValue $userValue): string
2123
{
22-
if (!$attribute->getTableName()) return '';
24+
if (!$attribute->getTableName()) {
25+
return '';
26+
}
2327

2428
$id = (int)($userValue->getValue() ?? 0);
2529
if ($id <= 0) {

0 commit comments

Comments
 (0)