Completed
Push — 4.x ( c12849...95977a )
by Cees-Jan
06:10 queued 04:05
created

Strings::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of TwigView.
5
 *
6
 ** (c) 2014 Cees-Jan Kiewiet
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace WyriHaximus\TwigView\Lib\Twig\Extension;
12
13
use Cake\Utility\Text;
14
15
/**
16
 * Class Strings
17
 * @package WyriHaximus\TwigView\Lib\Twig\Extension
18
 */
19
class Strings extends \Twig_Extension
20
{
21
22
    /**
23
     * Get declared filters.
24
     *
25
     * @return \Twig_SimpleFilter[]
26
     */
27 19
    public function getFilters()
28
    {
29
        return [
30 19
            new \Twig_SimpleFilter('substr', 'substr'),
31 19
            new \Twig_SimpleFilter('tokenize', 'Cake\Utility\Text::tokenize'),
32 19
            new \Twig_SimpleFilter('insert', 'Cake\Utility\Text::insert'),
33 19
            new \Twig_SimpleFilter('cleanInsert', 'Cake\Utility\Text::cleanInsert'),
34 19
            new \Twig_SimpleFilter('wrap', 'Cake\Utility\Text::wrap'),
35 19
            new \Twig_SimpleFilter('wrapBlock', 'Cake\Utility\Text::wrapBlock'),
36 19
            new \Twig_SimpleFilter('wordWrap', 'Cake\Utility\Text::wordWrap'),
37 19
            new \Twig_SimpleFilter('highlight', 'Cake\Utility\Text::highlight'),
38 19
            new \Twig_SimpleFilter('tail', 'Cake\Utility\Text::tail'),
39 19
            new \Twig_SimpleFilter('truncate', 'Cake\Utility\Text::truncate'),
40 19
            new \Twig_SimpleFilter('excerpt', 'Cake\Utility\Text::excerpt'),
41 19
            new \Twig_SimpleFilter('toList', 'Cake\Utility\Text::toList'),
42
            new \Twig_SimpleFilter('stripLinks', function ($string) {
43
                $previousrErrorHandler = set_error_handler(function () {
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $previousrErrorHandler exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
44 1
                });
45 1
                $strippedString = Text::stripLinks($string);
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Utility\Text::stripLinks() has been deprecated with message: 3.2.12 This method will be removed in 4.0.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
46 1
                set_error_handler($previousrErrorHandler);
47 1
                return $strippedString;
48 19
            }),
49 19
            new \Twig_SimpleFilter('isMultibyte', 'Cake\Utility\Text::isMultibyte'),
50 19
            new \Twig_SimpleFilter('utf8', 'Cake\Utility\Text::utf8'),
51 19
            new \Twig_SimpleFilter('ascii', 'Cake\Utility\Text::ascii'),
52 19
            new \Twig_SimpleFilter('parseFileSize', 'Cake\Utility\Text::parseFileSize'),
53 19
            new \Twig_SimpleFilter('none', function ($string) {
0 ignored issues
show
Unused Code introduced by
The parameter $string 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...
54 1
                return;
55 19
            }),
56 19
        ];
57
    }
58
59
    /**
60
     * Get declared functions.
61
     *
62
     * @return \Twig_SimpleFunction[]
63
     */
64 1
    public function getFunctions()
65
    {
66
        return [
67 1
            new \Twig_SimpleFunction('uuid', 'Cake\Utility\Text::uuid'),
68 1
        ];
69
    }
70
71
    /**
72
     * Get extension name.
73
     *
74
     * @return string
75
     */
76 1
    public function getName()
77
    {
78 1
        return 'string';
79
    }
80
}
81