Skip to content

Commit

Permalink
[TASK] Simplify code of existing rule
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Oct 10, 2023
1 parent beb8af7 commit 7aeff68
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public function transform(DOMDocument $domDocument): bool

$hasChanged = false;
foreach ($elements as $element) {
$types = $element->getElementsByTagName('type');

$type = $types->item(0);
$type = $element->getElementsByTagName('type')
->item(0);

if (! $type instanceof DOMElement) {
continue;
Expand All @@ -40,20 +39,18 @@ public function transform(DOMDocument $domDocument): bool
continue;
}

$renderTypes = $element->getElementsByTagName('renderType');

$renderType = $renderTypes->item(0);
$renderType = $element->getElementsByTagName('renderType')
->item(0);

if ($renderType instanceof \DOMElement) {
// If renderType is already set, migration can be skipped
if ($renderType instanceof DOMElement) {
continue;
}

$renderModes = $element->getElementsByTagName('renderMode');
$renderMode = $renderModes->item(0);

$sizes = $element->getElementsByTagName('size');

$size = $sizes->item(0);
$renderMode = $element->getElementsByTagName('renderMode')
->item(0);
$size = $element->getElementsByTagName('size')
->item(0);

$renderTypeName = 'selectSingle';
$insertBefore = $type;
Expand All @@ -68,11 +65,11 @@ public function transform(DOMDocument $domDocument): bool

$renderType = $domDocument->createElement('renderType', $renderTypeName);

if (! $insertBefore->parentNode instanceof \DOMNode) {
if (! $insertBefore->parentNode instanceof DOMNode) {
continue;
}

if (! $insertBefore->nextSibling instanceof \DOMNode) {
if (! $insertBefore->nextSibling instanceof DOMNode) {
continue;
}

Expand Down

0 comments on commit 7aeff68

Please sign in to comment.