Completed
Push — master ( 586888...6f962e )
by Paweł
16s
created

CallbackSchema::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\SettingsBundle\Schema;
13
14
use Symfony\Component\Form\FormBuilderInterface;
15
16
/**
17
 * @todo Remove and replace with anonymous classes after bump to PHP 7
18
 *
19
 * @author Kamil Kokot <[email protected]>
20
 */
21
final class CallbackSchema implements SchemaInterface
22
{
23
    /**
24
     * @var callable
25
     */
26
    private $buildSettings;
27
28
    /**
29
     * @var callable
30
     */
31
    private $buildForm;
32
33
    /**
34
     * @see SchemaInterface
35
     *
36
     * @param callable $buildSettings Receives the same arguments as SchemaInterface::buildSettings method
37
     * @param callable $buildForm Receives the same arguments as SchemaInterface::buildForm method
38
     */
39
    public function __construct(callable $buildSettings, callable $buildForm)
40
    {
41
        $this->buildSettings = $buildSettings;
42
        $this->buildForm = $buildForm;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function buildSettings(SettingsBuilderInterface $builder)
49
    {
50
        // Workaround for PHP 5
51
        $buildSettings = $this->buildSettings;
52
53
        $buildSettings($builder);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function buildForm(FormBuilderInterface $builder)
60
    {
61
        // Workaround for PHP 5
62
        $buildForm = $this->buildForm;
63
64
        $buildForm($builder);
65
    }
66
}
67