Skip to content

Commit

Permalink
Package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Oct 12, 2023
1 parent 03988bd commit 656e89d
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Classes/Detect/BrowserLanguageDetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __invoke(DetectUserLanguagesEvent $event): void
arsort($acceptedLanguagesArr);

// Remove quality 0.0
$acceptedLanguagesArr = array_filter($acceptedLanguagesArr, fn ($value, $key): bool => $value !== 0.0, \ARRAY_FILTER_USE_BOTH);
$acceptedLanguagesArr = array_filter($acceptedLanguagesArr, fn($value, $key): bool => $value !== 0.0, \ARRAY_FILTER_USE_BOTH);

$event->setUserLanguages(LocaleCollection::fromArray(array_keys($acceptedLanguagesArr)));
}
Expand Down
4 changes: 1 addition & 3 deletions Classes/Event/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Lochmueller\LanguageDetection\Event;

abstract class AbstractEvent
{
}
abstract class AbstractEvent {}
4 changes: 1 addition & 3 deletions Classes/Handler/Exception/AbstractHandlerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Lochmueller\LanguageDetection\Handler\Exception;

abstract class AbstractHandlerException extends \Exception
{
}
abstract class AbstractHandlerException extends \Exception {}
1 change: 1 addition & 0 deletions Classes/Negotiation/DefaultNegotiation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __invoke(NegotiateSiteLanguageEvent $event): void
'getLocale',
'getTwoLetterIsoCode',
];

$userLanguages = $this->normalizer->normalizeList($event->getUserLanguages());
foreach ($userLanguages->toArray() as $userLanguage) {
foreach ($event->getSite()->getLanguages() as $siteLanguage) {
Expand Down
4 changes: 1 addition & 3 deletions Classes/Service/IpLocationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Lochmueller\LanguageDetection\Service;

class IpLocationException extends \Exception
{
}
class IpLocationException extends \Exception {}
2 changes: 1 addition & 1 deletion Classes/Service/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Normalizer
{
public function normalizeList(LocaleCollection $locales): LocaleCollection
{
$result = array_map(fn (LocaleValueObject $locale): string => $this->normalize((string)$locale), $locales->toArray());
$result = array_map(fn(LocaleValueObject $locale): string => $this->normalize((string)$locale), $locales->toArray());

return LocaleCollection::fromArray($result);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Detect/GeoPluginDetectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testAddIpLanguageConfiguration(string $addIpLocationToBrowserLan
$ipLanguage = new GeoPluginDetect($ipLocation, new LanguageService(), new SiteConfigurationService(), new LocaleCollectionSortService());
$ipLanguage($event);

self::assertSame($result, array_map(fn ($locale): string => (string)$locale, $event->getUserLanguages()->toArray()));
self::assertSame($result, array_map(fn($locale): string => (string)$locale, $event->getUserLanguages()->toArray()));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions Tests/Unit/Event/AbstractEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@

use Lochmueller\LanguageDetection\Tests\Unit\AbstractUnitTest;

abstract class AbstractEventTest extends AbstractUnitTest
{
}
abstract class AbstractEventTest extends AbstractUnitTest {}
4 changes: 2 additions & 2 deletions Tests/Unit/Service/LocaleCollectionSortServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testDefaultSortingOfCollection(): void

$result = $sortService->addLocaleByMode($collection, new LocaleValueObject('en'));

self::assertSame(['de', 'en'], array_map(fn (LocaleValueObject $item): string => (string)$item, $result->toArray()));
self::assertSame(['de', 'en'], array_map(fn(LocaleValueObject $item): string => (string)$item, $result->toArray()));
}

/**
Expand All @@ -43,6 +43,6 @@ public function testReplaceSortingOfCollection(): void

$result = $sortService->addLocaleByMode($collection, new LocaleValueObject('en'), LocaleCollectionSortService::SORT_REPLACE);

self::assertSame(['en'], array_map(fn (LocaleValueObject $item): string => (string)$item, $result->toArray()));
self::assertSame(['en'], array_map(fn(LocaleValueObject $item): string => (string)$item, $result->toArray()));
}
}
4 changes: 2 additions & 2 deletions Tests/Unit/Service/NormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function testNormalizeList(): void
{
$normalizer = new Normalizer();

$base = array_map(fn ($item): string => $item[0], $this->normalizeProvider());
$base = array_map(fn($item): string => $item[0], $this->normalizeProvider());

$result = array_map(fn ($item): string => $item[1], $this->normalizeProvider());
$result = array_map(fn($item): string => $item[1], $this->normalizeProvider());

self::assertEquals(array_values($result), $normalizer->normalizeList(LocaleCollection::fromArray(array_values($base)))->toArray());
}
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"rector/rector": "^0.14",
"phpstan/phpstan": "^1.8",
"infection/infection": "^0.26",
"qossmic/deptrac-shim": "^0.24",
"qossmic/deptrac-shim": "^1.0",
"geoip2/geoip2": "^2.13",
"ssch/typo3-rector": "^1.0",
"phpstan/extension-installer": "^1.2"
Expand Down Expand Up @@ -88,6 +88,9 @@
"test:unit": [
"phpunit -c phpunit.xml --coverage-text --testdox"
],
"test:unit:tmp": [
"phpunit -c phpunit.xml --coverage-text --testdox --group=tmp"
],
"test:clover": [
"phpunit -c phpunit.xml --coverage-clover coverage.xml"
],
Expand Down

0 comments on commit 656e89d

Please sign in to comment.