Code Duplication    Length = 21-22 lines in 2 locations

src/CMS.php 1 location

@@ 224-245 (lines=22) @@
221
            require($collectionFile);
222
223
            // Iterate entity additional fields
224
            foreach ($metadata->allFieldCmsTypes as $fieldID => $fieldType) {
225
                // We need only gallery fields
226
                if ($fieldType === Field::TYPE_GALLERY) {
227
228
                    $fieldName = $metadata->allFieldIDs[$fieldID];
229
                    // Declare class
230
                    $this->generateQuerableClassHeader(
231
                        $metadata,
232
                        ucfirst($fieldName) . 'Gallery',
233
                        '\\' . \samsoncms\api\Gallery::class,
234
                        array(\samsoncms\api\Renderable::class)
235
                    );
236
237
                    return $this->generator
238
                        ->text($this->generateConstructorGalleryClass(
239
                            $metadata->entity . '::F_' . strtoupper($fieldName) . '_ID',
240
                            $metadata->entity
241
                        ))
242
                        ->endClass()
243
                        ->flush();
244
                }
245
            }
246
        }
247
248
//        // Generate entities classes file

src/GeneratorApi.php 1 location

@@ 441-461 (lines=21) @@
438
    public function createGalleryClass(Metadata $metadata)
439
    {
440
        // Iterate entity additional fields
441
        foreach ($metadata->allFieldCmsTypes as $fieldID => $fieldType) {
442
            // We need only gallery fields
443
            if ($fieldType === Field::TYPE_GALLERY) {
444
                $fieldName = $metadata->allFieldIDs[$fieldID];
445
                // Declare class
446
                $this->generateQuerableClassHeader(
447
                    $metadata,
448
                    ucfirst($fieldName) . 'Gallery',
449
                    '\\' . \samsoncms\api\Gallery::class,
450
                    array(\samsoncms\api\Renderable::class)
451
                );
452
453
                return $this->generator
454
                    ->text($this->generateConstructorGalleryClass(
455
                        $metadata->entity . '::F_' . strtoupper($fieldName) . '_ID',
456
                        $metadata->entity
457
                    ))
458
                    ->endClass()
459
                    ->flush();
460
            }
461
        }
462
463
464
    }