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

ObjectToTabellaExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 21
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 5 1
A field2Object() 0 4 1
A object2View() 0 4 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