Code Duplication    Length = 33-33 lines in 2 locations

src/Oro/Bundle/EntityConfigBundle/Config/ConfigModelManager.php 2 locations

@@ 297-329 (lines=33) @@
294
     * @throws \InvalidArgumentException if $className, $fieldName or $fieldType is empty
295
     * @throws RuntimeException if models are locked
296
     */
297
    public function changeFieldType($className, $fieldName, $fieldType)
298
    {
299
        if (empty($className)) {
300
            throw new \InvalidArgumentException('$className must not be empty');
301
        }
302
        if (empty($fieldName)) {
303
            throw new \InvalidArgumentException('$fieldName must not be empty');
304
        }
305
        if (empty($fieldType)) {
306
            throw new \InvalidArgumentException('$fieldType must not be empty');
307
        }
308
        if ($this->lockObject->isLocked()) {
309
            throw new RuntimeException(
310
                sprintf(
311
                    'Cannot change field type for "%s::%s" because config models are locked.',
312
                    $className,
313
                    $fieldName
314
                )
315
            );
316
        }
317
318
        $result     = false;
319
        $fieldModel = $this->findFieldModel($className, $fieldName);
320
        if ($fieldModel && $fieldModel->getType() !== $fieldType) {
321
            $fieldModel->setType($fieldType);
322
            $this->getEntityManager()->persist($fieldModel);
323
324
            $this->fields[$className][$fieldName] = $fieldModel;
325
            $result                               = true;
326
        }
327
328
        return $result;
329
    }
330
331
    /**
332
     * Changes a mode of a field
@@ 344-376 (lines=33) @@
341
     * @throws \InvalidArgumentException if $className, $fieldName or $mode is empty
342
     * @throws RuntimeException if models are locked
343
     */
344
    public function changeFieldMode($className, $fieldName, $mode)
345
    {
346
        if (empty($className)) {
347
            throw new \InvalidArgumentException('$className must not be empty');
348
        }
349
        if (empty($fieldName)) {
350
            throw new \InvalidArgumentException('$fieldName must not be empty');
351
        }
352
        if (empty($mode)) {
353
            throw new \InvalidArgumentException('$mode must not be empty');
354
        }
355
        if ($this->lockObject->isLocked()) {
356
            throw new RuntimeException(
357
                sprintf(
358
                    'Cannot change field mode for "%s::%s" because config models are locked.',
359
                    $className,
360
                    $fieldName
361
                )
362
            );
363
        }
364
365
        $result     = false;
366
        $fieldModel = $this->findFieldModel($className, $fieldName);
367
        if ($fieldModel && $fieldModel->getMode() !== $mode) {
368
            $fieldModel->setMode($mode);
369
            $this->getEntityManager()->persist($fieldModel);
370
371
            $this->fields[$className][$fieldName] = $fieldModel;
372
            $result                               = true;
373
        }
374
375
        return $result;
376
    }
377
378
    /**
379
     * Changes a mode of an entity