Completed
Push — 4.1 ( fe3b41...c2b28b )
by Andrea
12:59
created

ObjectToTabellaExtension::field2Object()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Fi\CoreBundle\Twig\Extension;
4
5
use Fi\CoreBundle\Utils\Entity\DoctrineFieldReader;
6
7
class ObjectToTabellaExtension extends \Twig_Extension
8
{
9
10
    public function getFunctions()
11
    {
12
        return array(
13
            new \Twig_SimpleFunction('object2view', array($this, 'object2View', 'is_safe' => array('html'))),
14
            new \Twig_SimpleFunction('field2object', array($this, 'field2Object', 'is_safe' => array('html'))),
15
        );
16
    }
17
18 6
    public function object2View($object, $type = null)
19
    {
20 6
        $dfr = new DoctrineFieldReader($object);
21 6
        return $dfr->object2View($object, $type);
22
    }
23
24 6
    public function field2Object($fieldtoobj, $object)
25
    {
26 6
        $dfr = new DoctrineFieldReader($object);
27 6
        return $dfr->getField2Object($fieldtoobj);
28
    }
29
}
30