Completed
Push — master ( 22860b...81e1d8 )
by Alessandro
02:32
created

FacileMongoDbBundleExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 50
ccs 4
cts 9
cp 0.4444
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 7 1
A queryFilterTranslate() 0 4 1
A queryDataTranslate() 0 4 1
A getName() 0 4 1
1
<?php declare(strict_types = 1);
2
3
namespace Facile\MongoDbBundle\Twig;
4
5
class FacileMongoDbBundleExtension extends \Twig_Extension
6
{
7
    private $methodDataTranslationMap  = [
8
        'aggregate' => 'Pipeline',
9
        'insertOne' => 'Document',
10
        'updateOne' => 'Update',
11
        'findOneAndUpdate' => 'Update',
12
        'replaceOne' => 'Replacement',
13
    ];
14
15
    public function getFunctions()
16
    {
17
        return [
18
            new \Twig_Simplefunction('filterLabelTranslate', array($this, 'queryFilterTranslate')),
19
            new \Twig_Simplefunction('dataLabelTranslate', array($this, 'queryDataTranslate')),
20
        ];
21
    }
22
23
    /**
24
     * @param string $label
25
     * @param string $methodName
26
     *
27
     * @return string
28
     */
29 1
    public function queryFilterTranslate(string $label, string $methodName): string
0 ignored issues
show
Unused Code introduced by
The parameter $methodName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31 1
        return $label;
32
    }
33
34
    /**
35
     * @param string $label
36
     * @param string $methodName
37
     *
38
     * @return string
39
     */
40 6
    public function queryDataTranslate(string $label, string $methodName): string
41
    {
42 6
        return $this->methodDataTranslationMap[$methodName] ?? $label;
43
    }
44
45
    /**
46
     * Returns the name of the extension.
47
     *
48
     * @return string The extension name
49
     */
50
    public function getName()
51
    {
52
        return 'facile_mongo_db_extesion';
53
    }
54
}