apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -12,15 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Search\Utils;
use libphonenumber\PhoneNumberUtil;
use LogicException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use function count;
use function implode;
use function preg_match;
use function str_split;
use function strtr;
use function trim;
class ExtractPhonenumberFromPattern
{
@@ -36,19 +28,19 @@ class ExtractPhonenumberFromPattern
public function extractPhonenumber(string $subject): SearchExtractionResult
{
$matches = [];
preg_match(self::PATTERN, $subject, $matches);
\preg_match(self::PATTERN, $subject, $matches);
if (0 < count($matches)) {
if (0 < \count($matches)) {
$phonenumber = [];
$length = 0;
foreach (str_split(trim($matches[0])) as $key => $char) {
foreach (\str_split(\trim($matches[0])) as $key => $char) {
switch ($char) {
case '+':
if (0 === $key) {
$phonenumber[] = $char;
} else {
throw new LogicException('should not match not alnum character');
throw new \LogicException('should not match not alnum character');
}
break;
@@ -58,7 +50,7 @@ class ExtractPhonenumberFromPattern
if (0 === $key) {
$util = PhoneNumberUtil::getInstance();
$phonenumber[] = '+' . $util->getCountryCodeForRegion($this->defaultCarrierCode);
$phonenumber[] = '+'.$util->getCountryCodeForRegion($this->defaultCarrierCode);
} else {
$phonenumber[] = $char;
}
@@ -83,14 +75,14 @@ class ExtractPhonenumberFromPattern
break;
default:
throw new LogicException('should not match not alnum character');
throw new \LogicException('should not match not alnum character');
}
}
if (5 < $length) {
$filtered = trim(strtr($subject, [$matches[0] => '']));
$filtered = \trim(\strtr($subject, [$matches[0] => '']));
return new SearchExtractionResult($filtered, [implode('', $phonenumber)]);
return new SearchExtractionResult($filtered, [\implode('', $phonenumber)]);
}
}