GalleryHasMediaAdmin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureFormFields() 0 16 1
1
<?php
2
3
namespace App\Admin;
4
5
use Sonata\AdminBundle\Form\FormMapper;
6
use Sonata\AdminBundle\Form\Type\ModelListType;
7
use Sonata\MediaBundle\Admin\GalleryHasMediaAdmin as BaseGalleryHasMediaAdmin;
8
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
9
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
10
use Symfony\Component\Form\Extension\Core\Type\TextType;
11
12
class GalleryHasMediaAdmin extends BaseGalleryHasMediaAdmin
13
{
14
    /**
15
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
16
     *
17
     * @return void
18
     */
19
    protected function configureFormFields(FormMapper $formMapper)
20
    {
21
        parent::configureFormFields($formMapper);
22
23
        $mediaField = $field = $formMapper->get('media');
0 ignored issues
show
Unused Code introduced by
$field is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24
        $options    = $mediaField->getFormConfig()->getOptions();
25
        $options['btn_delete'] = false;
26
27
        $formMapper
28
            ->remove('enabled')
29
            ->remove('position')
30
            ->add('title', null, ['label' => 'Title', 'attr' => ['style' => 'height: 150px']])
31
            ->add('description', null, ['attr' => ['style' => 'height: 150px; width: 400px']])
32
            ->add('media', ModelListType::class, $options)
33
        ;
34
    }
35
}
36