Code Duplication    Length = 10-10 lines in 2 locations

src/Traits/MultiUnitSupport.php 2 locations

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