SearchBoxType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 20
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 10 1
A configureOptions() 0 3 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
12
13
use BitBag\SyliusElasticsearchPlugin\Model\SearchBox;
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\Extension\Core\Type\SearchType as SymfonySearchType;
16
use Symfony\Component\Form\FormBuilderInterface;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
use Symfony\Component\Validator\Constraints\NotBlank;
19
20
final class SearchBoxType extends AbstractType
21
{
22
    public function buildForm(FormBuilderInterface $builder, array $options): void
23
    {
24
        $builder
25
            ->add(
26
                'query',
27
                SymfonySearchType::class,
28
                [
29
                    'label' => false,
30
                    'attr' => ['placeholder' => 'bitbag_sylius_elasticsearch_plugin.ui.search_box.query.placeholder'],
31
                    'constraints' => [new NotBlank()],
32
                ]
33
            )
34
        ;
35
    }
36
37
    public function configureOptions(OptionsResolver $resolver): void
38
    {
39
        $resolver->setDefault('data_class', SearchBox::class);
40
    }
41
}
42