Code Duplication    Length = 26-26 lines in 2 locations

src/Tokens/Elements/Html.php 2 locations

@@ 115-140 (lines=26) @@
112
        }
113
114
        // Handle multiple HEAD elements.
115
        if ($headCount > 1) {
116
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_THROW) {
117
                throw new ValidationException('HTML element can only have 1 HEAD element child.');
118
            }
119
120
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_REMOVE) {
121
                return false;
122
            }
123
124
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_FIX) {
125
                // Remove extraneous HEAD elements.
126
                $keepHead = true;
127
                foreach ($this->children as $key => $child) {
128
                    if ($child->getType() == 'element' && $child->getName() == 'head') {
129
                        if ($keepHead) {
130
                            $keepHead = false;
131
                        } else {
132
                            unset($this->children[$key]);
133
                            if ($logger !== null) {
134
                                $logger->debug('Removed extraneous HEAD element.');
135
                            }
136
                        }
137
                    }
138
                }
139
            }
140
        }
141
142
        // Handle multiple BODY elements.
143
        if ($bodyCount > 1) {
@@ 143-168 (lines=26) @@
140
        }
141
142
        // Handle multiple BODY elements.
143
        if ($bodyCount > 1) {
144
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_THROW) {
145
                throw new ValidationException('HTML element can only have 1 BODY element child.');
146
            }
147
148
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_REMOVE) {
149
                return false;
150
            }
151
152
            if ($this->configuration->get('error-strategy') == Configuration::ERROR_STRATEGY_FIX) {
153
                // Remove extraneous BODY elements.
154
                $keepBody = true;
155
                foreach ($this->children as $key => $child) {
156
                    if ($child->getType() == 'element' && $child->getName() == 'body') {
157
                        if ($keepBody) {
158
                            $keepBody = false;
159
                        } else {
160
                            unset($this->children[$key]);
161
                            if ($logger !== null) {
162
                                $logger->debug('Removed extraneous BODY element.');
163
                            }
164
                        }
165
                    }
166
                }
167
            }
168
        }
169
170
        // Handle BODY before HEAD.
171
        if (!$headIsFirst && $bodyCount > 0) {