mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-23 23:25:00 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,9 +17,6 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
|
||||
class PersonAltNameDataMapper implements DataMapperInterface
|
||||
{
|
||||
public function mapDataToForms($viewData, $forms)
|
||||
@@ -35,12 +32,12 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
$mapIndexToKey = [];
|
||||
|
||||
foreach ($viewData->getIterator() as $key => $altName) {
|
||||
/** @var PersonAltName $altName */
|
||||
/* @var PersonAltName $altName */
|
||||
$mapIndexToKey[$altName->getKey()] = $key;
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
if (array_key_exists($key, $mapIndexToKey)) {
|
||||
if (\array_key_exists($key, $mapIndexToKey)) {
|
||||
$form->setData($viewData->get($mapIndexToKey[$key])->getLabel());
|
||||
}
|
||||
}
|
||||
@@ -48,13 +45,13 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
|
||||
/**
|
||||
* @param FormInterface[] $forms
|
||||
* @param Collection $viewData
|
||||
* @param Collection $viewData
|
||||
*/
|
||||
public function mapFormsToData($forms, &$viewData)
|
||||
{
|
||||
$mapIndexToKey = [];
|
||||
|
||||
if (is_array($viewData)) {
|
||||
if (\is_array($viewData)) {
|
||||
$dataIterator = $viewData;
|
||||
} else {
|
||||
$dataIterator = $viewData instanceof ArrayCollection ?
|
||||
@@ -62,14 +59,14 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
}
|
||||
|
||||
foreach ($dataIterator as $key => $altName) {
|
||||
/** @var PersonAltName $altName */
|
||||
/* @var PersonAltName $altName */
|
||||
$mapIndexToKey[$altName->getKey()] = $key;
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
$isEmpty = empty($form->getData());
|
||||
|
||||
if (array_key_exists($key, $mapIndexToKey)) {
|
||||
if (\array_key_exists($key, $mapIndexToKey)) {
|
||||
if ($isEmpty) {
|
||||
$viewData->remove($mapIndexToKey[$key]);
|
||||
} else {
|
||||
@@ -81,7 +78,7 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
->setKey($key)
|
||||
->setLabel($form->getData());
|
||||
|
||||
if (is_array($viewData)) {
|
||||
if (\is_array($viewData)) {
|
||||
$viewData[] = $altName;
|
||||
} else {
|
||||
$viewData->add($altName);
|
||||
|
Reference in New Issue
Block a user