FormId   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of slick/form package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Form\Parser\Worker;
11
12
use Slick\Form\Element\ContainerInterface;
13
use Slick\Form\FormInterface;
14
use Slick\Form\Input\Hidden;
15
use Slick\Form\Parser\WorkerInterface;
16
17
/**
18
 * Adds form id to the form
19
 *
20
 * @package Slick\Form\Parser\Worker
21
 */
22
class FormId implements WorkerInterface
23
{
24
25
    /**
26
     * Adds or changes a specific aspect of provided from
27
     *
28
     * @param ContainerInterface|FormInterface $form
29
     * @param array $data
30
     *
31
     * @return void
32
     */
33 12
    public static function execute(ContainerInterface $form, array $data)
34
    {
35 12
        $input = new Hidden();
36 12
        $input->setValue($data['id'])
37 12
            ->setName('form-id');
38 12
        if ($form instanceof FormInterface) {
39 12
            $form->setId($data['id']);
40 12
        }
41 12
        $form->add($input);
42
    }
43
}