ResourceExpressionLanguage   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 1
c 2
b 0
f 2
lcom 0
cbo 1
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B registerFunctions() 0 24 1
1
<?php
2
3
namespace DoS\ResourceBundle\ExpressionLanguage;
4
5
use Sylius\Bundle\ResourceBundle\ExpressionLanguage\ExpressionLanguage;
6
7
class ResourceExpressionLanguage extends ExpressionLanguage
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    protected function registerFunctions()
13
    {
14
        parent::registerFunctions();
15
16
        $this->register(
17
            'getCurrentUser',
18
            function ($arg) {
19
                return sprintf('$this->get("security.token_storage")->getToken()->getUser()', $arg);
20
            },
21
            function (array $variables) {
22
                return $variables['container']->get('security.token_storage')->getToken()->getUser();
23
            }
24
        );
25
26
        $this->register(
27
            'getQueryParam',
28
            function ($limitKey, $default) {
29
                return sprintf('$this->get("request")->get(%s, %s)', $limitKey, $default);
30
            },
31
            function (array $variables, $limitKey, $default) {
32
                return $variables['container']->get('request')->get($limitKey, $default);
33
            }
34
        );
35
    }
36
}
37