ModuleType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 95.45%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 3
c 3
b 0
f 2
lcom 0
cbo 6
dl 0
loc 70
ccs 42
cts 44
cp 0.9545
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 55 1
A getBlockPrefix() 0 4 1
A configureOptions() 0 6 1
1
<?php
2
3
namespace AppBundle\Form;
4
5
use Doctrine\ORM\EntityRepository;
6
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
7
use Symfony\Component\Form\AbstractType;
8
use Symfony\Component\Form\Extension\Core\Type\FileType;
9
use Symfony\Component\Form\Extension\Core\Type\TextType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\Form\FormEvent;
12
use Symfony\Component\Form\FormEvents;
13
use Symfony\Component\OptionsResolver\OptionsResolver;
14
15
class ModuleType extends AbstractType
16
{
17 2
    public function buildForm(FormBuilderInterface $builder, array $options)
18
    {
19
        $builder
20 2
            ->add('title', TextType::class, [
21
                'attr' => [
22 2
                    'class' => 'form-control',
23
                    'placeholder' => 'enter title'
24 2
                ]
25 2
            ])
26 2
            ->add('rating', TextType::class,[
27
                'attr' => [
28 2
                    'class' => 'form-control',
29
                    'placeholder' => 'enter rating'
30 2
                ]
31 2
            ])
32 2
            ->add('persentSuccess', TextType::class,[
33
                'attr' => [
34 2
                    'class' => 'form-control',
35
                    'placeholder' => 'enter persent'
36 2
                ]
37 2
            ])
38 2
            ->add('time', TextType::class,[
39
                'attr' => [
40 2
                    'class' => 'form-control',
41
                    'placeholder' => 'enter time'
42 2
                ]
43 2
            ])
44 2
            ->add('attempts', TextType::class,[
45
                'attr' => [
46 2
                    'class' => 'form-control',
47
                    'placeholder' => 'enter attempts'
48 2
                ]
49 2
            ])
50 2
            ->add('category', EntityType::class, [
51 2
                'class' => 'AppBundle\Entity\Category',
52
                'query_builder' => function (EntityRepository $er) {
53 2
                    return $er->createQueryBuilder('c')
54 2
                        ->orderBy('c.title', 'ASC');
55 2
                },
56 2
                'label' => 'Category',
57 2
                'property' => 'title',
58 2
                'attr' => ['class' => 'chosen-select'],
59
                'required'  => true
60 2
            ])
61 2
            ->add('module_image', FileType::class, [
62
                'required' => false
63 2
            ])
64 2
            ->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event)  {
65
                $data = $event->getData();
66
67
68
69
                $event->setData($data);
70 2
            });
71 2
    }
72
73 2
    public function configureOptions(OptionsResolver $resolver)
74
    {
75 2
        $resolver->setDefaults(array(
76 2
            'data_class' => 'AppBundle\Entity\Module',
77 2
        ));
78 2
    }
79
80 2
    public function getBlockPrefix()
81
    {
82 2
        return 'app_bundle_module_type';
83
    }
84
}
85