Completed
Push — master ( e2b1b5...0394bc )
by Ryan
02:27
created

UsersModulePlugin::getFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php namespace Anomaly\UsersModule;
2
3
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
4
use Anomaly\Streams\Platform\Support\Decorator;
5
use Anomaly\UsersModule\Role\Command\GetRole;
6
use Anomaly\UsersModule\User\Command\GetUser;
7
use Anomaly\UsersModule\User\UserMentions;
8
9
/**
10
 * Class UsersModulePlugin
11
 *
12
 * @link          http://pyrocms.com/
13
 * @author        PyroCMS, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 */
16
class UsersModulePlugin extends Plugin
17
{
18
19
    /**
20
     * Get the functions.
21
     *
22
     * @return array
23
     */
24
    public function getFunctions()
25
    {
26
        return [
27
            new \Twig_SimpleFunction(
28
                'user',
29
                function ($identifier = null) {
30
                    return (new Decorator())->decorate($this->dispatch(new GetUser($identifier)));
31
                }
32
            ),
33
            new \Twig_SimpleFunction(
34
                'role',
35
                function ($identifier) {
36
                    return (new Decorator())->decorate($this->dispatch(new GetRole($identifier)));
37
                }
38
            ),
39
            new \Twig_SimpleFunction(
40
                'mentions_*',
41 View Code Duplication
                function ($name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
                    $arguments = array_slice(func_get_args(), 1);
43
44
                    return call_user_func_array([app(UserMentions::class), camel_case($name)], $arguments);
45
                },
46
                [
47
                    'is_safe' => ['html'],
48
                ]
49
            ),
50
        ];
51
    }
52
53
    /**
54
     * Get the filters.
55
     *
56
     * @return array
57
     */
58 View Code Duplication
    public function getFilters()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        return [
61
            new \Twig_SimpleFilter(
62
                'mentions_*',
63
                function ($name) {
64
                    $arguments = array_slice(func_get_args(), 1);
65
66
                    return call_user_func_array([app(UserMentions::class), camel_case($name)], $arguments);
67
                }
68
            ),
69
        ];
70
    }
71
}
72