Code Duplication    Length = 10-10 lines in 2 locations

src/Traits/MultiUnitSupport.php 2 locations

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