TypogrifyTwigExtension::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Typogrify plugin for Craft CMS
4
 *
5
 * Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more
6
 *
7
 * @link      https://nystudio107.com/
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\typogrify\twigextensions;
12
13
use nystudio107\typogrify\Typogrify;
14
use Twig\Extension\AbstractExtension;
15
use Twig\TwigFilter;
16
use Twig\TwigFunction;
17
18
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   Typogrify
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     1.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
23
class TypogrifyTwigExtension extends AbstractExtension
24
{
25
    // Public Methods
26
    // =========================================================================
27
28
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
29
     * @inheritdoc
30
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
31
    public function getName(): string
32
    {
33
        return 'Typogrify';
34
    }
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @inheritdoc
38
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
39
    public function getFilters(): array
40
    {
41
        $variable = Typogrify::$variable;
42
        return [
43
            new TwigFilter('typogrify', [$variable, 'typogrify']),
44
            new TwigFilter('typogrifyFeed', [$variable, 'typogrifyFeed']),
45
            new TwigFilter('smartypants', [$variable, 'smartypants']),
46
            new TwigFilter('truncate', [$variable, 'truncate']),
47
            new TwigFilter('truncateOnWord', [$variable, 'truncateOnWord']),
48
            new TwigFilter('stringy', [$variable, 'stringy']),
49
            new TwigFilter('humanFileSize', [$variable, 'humanFileSize']),
50
            new TwigFilter('humanDuration', [$variable, 'humanDuration']),
51
            new TwigFilter('humanRelativeTime', [$variable, 'humanRelativeTime']),
52
            new TwigFilter('ordinalize', [$variable, 'ordinalize']),
53
            new TwigFilter('pluralize', [$variable, 'pluralize']),
54
            new TwigFilter('singularize', [$variable, 'singularize']),
55
            new TwigFilter('transliterate', [$variable, 'transliterate']),
56
            new TwigFilter('wordLimit', [$variable, 'wordLimit']),
57
        ];
58
    }
59
60
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
61
     * @inheritdoc
62
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
63
    public function getFunctions(): array
64
    {
65
        $variable = Typogrify::$variable;
66
        return [
67
            new TwigFunction('typogrify', [$variable, 'typogrify']),
68
            new TwigFunction('typogrifyFeed', [$variable, 'typogrifyFeed']),
69
            new TwigFunction('smartypants', [$variable, 'smartypants']),
70
            new TwigFunction('getPhpTypographySettings', [$variable, 'getPhpTypographySettings']),
71
            new TwigFunction('truncate', [$variable, 'truncate']),
72
            new TwigFunction('truncateOnWord', [$variable, 'truncateOnWord']),
73
            new TwigFunction('stringy', [$variable, 'stringy']),
74
            new TwigFunction('humanFileSize', [$variable, 'humanFileSize']),
75
            new TwigFunction('humanDuration', [$variable, 'humanDuration']),
76
            new TwigFunction('humanRelativeTime', [$variable, 'humanRelativeTime']),
77
            new TwigFunction('ordinalize', [$variable, 'ordinalize']),
78
            new TwigFunction('pluralize', [$variable, 'pluralize']),
79
            new TwigFunction('singularize', [$variable, 'singularize']),
80
            new TwigFunction('transliterate', [$variable, 'transliterate']),
81
            new TwigFunction('wordLimit', [$variable, 'wordLimit']),
82
        ];
83
    }
84
}
85