apply rules rector

This commit is contained in:
2023-07-19 22:48:26 +02:00
parent 6e6f19c499
commit 74ed34ba97
40 changed files with 250 additions and 697 deletions

View File

@@ -45,28 +45,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
'compositionType',
];
private ExportAddressHelper $addressHelper;
private AggregateStringHelper $aggregateStringHelper;
private EntityManagerInterface $entityManager;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringExportLabelHelper $translatableStringHelper;
public function __construct(
ExportAddressHelper $addressHelper,
AggregateStringHelper $aggregateStringHelper,
EntityManagerInterface $entityManager,
RollingDateConverterInterface $rollingDateConverter,
TranslatableStringExportLabelHelper $translatableStringHelper
private ExportAddressHelper $addressHelper,
private AggregateStringHelper $aggregateStringHelper,
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
private TranslatableStringExportLabelHelper $translatableStringHelper
) {
$this->addressHelper = $addressHelper;
$this->aggregateStringHelper = $aggregateStringHelper;
$this->entityManager = $entityManager;
$this->rollingDateConverter = $rollingDateConverter;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder)
@@ -100,27 +85,21 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
if (substr($key, 0, strlen('address_fields')) === 'address_fields') {
if (str_starts_with($key, 'address_fields')) {
return $this->addressHelper->getLabel($key, $values, $data, 'address_fields');
}
switch ($key) {
case 'membersId':
case 'membersName':
return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key);
return match ($key) {
'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key),
'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key),
default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.household.' . $key;
}
case 'compositionType':
return $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key);
default:
return static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.household.' . $key;
}
return (string) $value;
};
}
return (string) $value;
},
};
}
public function getQueryKeys($data): array

View File

@@ -39,16 +39,8 @@ class StepFilterBetweenDates implements FilterInterface
'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG,
];
private RollingDateConverterInterface $rollingDateConverter;
private TranslatorInterface $translator;
public function __construct(
RollingDateConverterInterface $rollingDateConverter,
TranslatorInterface $translator
) {
$this->rollingDateConverter = $rollingDateConverter;
$this->translator = $translator;
public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator)
{
}
public function addRole(): ?string

View File

@@ -92,129 +92,104 @@ final readonly class ListAccompanyingPeriodHelper
return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields');
}
switch ($key) {
case 'stepSince':
case 'openingDate':
case 'closingDate':
case 'referrerSince':
case 'acpCreatedAt':
case 'acpUpdatedAt':
return $this->dateTimeHelper->getLabel('export.list.acp.' . $key);
return match ($key) {
'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key),
'origin', 'closingMotive', 'job' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
case 'origin':
case 'closingMotive':
case 'job':
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) {
return '';
}
if (null === $value) {
return '';
}
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
},
'locationPersonName', 'requestorPerson' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
};
if (null === $value || null === $person = $this->personRepository->find($value)) {
return '';
}
case 'locationPersonName':
case 'requestorPerson':
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
return $this->personRender->renderString($person, []);
},
'requestorThirdParty' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value || null === $person = $this->personRepository->find($value)) {
return '';
}
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
return '';
}
return $this->personRender->renderString($person, []);
};
return $this->thirdPartyRender->renderString($thirdparty, []);
},
'scopes' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
case 'requestorThirdParty':
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) {
return '';
}
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
return '';
}
return implode(
'|',
array_map(
fn ($s) => $this->translatableStringHelper->localize($s),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
)
);
},
'socialIssues' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
return $this->thirdPartyRender->renderString($thirdparty, []);
};
if (null === $value) {
return '';
}
case 'scopes':
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
return implode(
'|',
array_map(
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
)
);
},
'step' => fn ($value) => match ($value) {
'_header' => 'export.list.acp.step',
null => '',
AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'),
AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'),
AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'),
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'),
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'),
default => $value,
},
'intensity' => fn ($value) => match ($value) {
'_header' => 'export.list.acp.intensity',
null => '',
AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'),
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
default => $value,
},
default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) {
return '';
}
if (null === $value) {
return '';
}
return implode(
'|',
array_map(
fn ($s) => $this->translatableStringHelper->localize($s),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
)
);
};
case 'socialIssues':
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) {
return '';
}
return implode(
'|',
array_map(
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
)
);
};
case 'step':
return fn ($value) => match ($value) {
'_header' => 'export.list.acp.step',
null => '',
AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'),
AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'),
AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'),
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'),
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'),
default => $value,
};
case 'intensity':
return fn ($value) => match ($value) {
'_header' => 'export.list.acp.intensity',
null => '',
AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'),
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
default => $value,
};
default:
return static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) {
return '';
}
return $value;
};
}
return $value;
},
};
}
public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void