Code Duplication    Length = 10-10 lines in 2 locations

src/Traits/MultiUnitSupport.php 2 locations

@@ 226-235 (lines=10) @@
223
    {
224
        if ($this->isMultiUnitField($field)) {
225
            $found = false;
226
            foreach ($this->getMultiUnitFieldSupportedUnits($field) as $unitClass) {
227
                /**
228
                 * @var AbstractUnit $unit
229
                 */
230
                $supportedUnit = new $unitClass();
231
                if (strtolower($supportedUnit->getId()) == strtolower($unit)) {
232
                    $found = true;
233
                    break;
234
                }
235
            }
236
            if ($found) {
237
                $this->multiUnitSelectedUnits[$field] = $unitClass;
238
            } else {
@@ 261-270 (lines=10) @@
258
                if (is_null($unit)) {
259
                    $unit = $this->getMultiUnitFieldUnit($field);
260
                } else {
261
                    foreach ($this->getMultiUnitFieldSupportedUnits($field) as $unitClass) {
262
                        /**
263
                         * @var AbstractUnit $unit
264
                         */
265
                        $supportedUnit = new $unitClass();
266
                        if (strtolower($supportedUnit->getId()) == strtolower($unit)) {
267
                            $unit = $supportedUnit;
268
                            break;
269
                        }
270
                    }
271
                }
272
                if (is_string($unit)) {
273
                    throw new NotSupportedMultiUnitField($field);