SonataDoctrinePHPCRAdminExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilters() 0 7 1
A renderNodeProperty() 0 4 1
A renderNodePath() 0 4 1
A getName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrinePHPCRAdminBundle\Twig\Extension;
15
16
use PHPCR\NodeInterface;
17
18
class SonataDoctrinePHPCRAdminExtension extends \Twig_Extension
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getFilters()
24
    {
25
        return [
26
            new \Twig_SimpleFilter('render_node_property', [$this, 'renderNodeProperty'], ['is_safe' => ['html']]),
27
            new \Twig_SimpleFilter('render_node_path', [$this, 'renderNodePath'], ['is_safe' => ['html']]),
28
        ];
29
    }
30
31
    /**
32
     * Renders a property of a node.
33
     *
34
     * @param string $property
35
     *
36
     * @return string String representation of the property
37
     */
38
    public function renderNodeProperty(NodeInterface $node, $property)
39
    {
40
        return $node->getProperty($property)->getString();
41
    }
42
43
    /**
44
     * Renders a path of a node.
45
     *
46
     * @return string Node path
47
     */
48
    public function renderNodePath(NodeInterface $node)
49
    {
50
        return $node->getPath();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getName()
57
    {
58
        return 'sonata_doctrine_phpcr_admin';
59
    }
60
}
61