FormId::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 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
}