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

FacileMongoDbBundleExtension::queryDataTranslate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 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
}