• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 8678307574

14 Apr 2024 04:14AM UTC coverage: 84.44%. Remained the same
8678307574

push

github

web-flow
Merge pull request #8783 from codeigniter4/develop

4.5.1 Ready code

24 of 32 new or added lines in 12 files covered. (75.0%)

164 existing lines in 12 files now uncovered.

20318 of 24062 relevant lines covered (84.44%)

188.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/system/View/Plugins.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\View;
15

16
use CodeIgniter\HTTP\URI;
17

18
/**
19
 * View plugins
20
 */
21
class Plugins
22
{
23
    /**
24
     * Wrap helper function to use as view plugin.
25
     *
26
     * @return string|URI
27
     */
28
    public static function currentURL()
29
    {
30
        return current_url();
1✔
31
    }
32

33
    /**
34
     * Wrap helper function to use as view plugin.
35
     *
36
     * @return string|URI
37
     */
38
    public static function previousURL()
39
    {
40
        return previous_url();
1✔
41
    }
42

43
    /**
44
     * Wrap helper function to use as view plugin.
45
     *
46
     * @param array{email?: string, title?: string, attributes?: array<string, string>|object|string} $params
47
     */
48
    public static function mailto(array $params = []): string
49
    {
50
        $email = $params['email'] ?? '';
2✔
51
        $title = $params['title'] ?? '';
2✔
52
        $attrs = $params['attributes'] ?? '';
2✔
53

54
        return mailto($email, $title, $attrs);
2✔
55
    }
56

57
    /**
58
     * Wrap helper function to use as view plugin.
59
     *
60
     * @param array{email?: string, title?: string, attributes?: array<string, string>|object|string} $params
61
     */
62
    public static function safeMailto(array $params = []): string
63
    {
64
        $email = $params['email'] ?? '';
1✔
65
        $title = $params['title'] ?? '';
1✔
66
        $attrs = $params['attributes'] ?? '';
1✔
67

68
        return safe_mailto($email, $title, $attrs);
1✔
69
    }
70

71
    /**
72
     * Wrap helper function to use as view plugin.
73
     *
74
     * @param array<int|string, string>|list<string> $params
75
     */
76
    public static function lang(array $params = []): string
77
    {
78
        $line = array_shift($params);
1✔
79

80
        return lang($line, $params);
1✔
81
    }
82

83
    /**
84
     * Wrap helper function to use as view plugin.
85
     *
86
     * @param array{field?: string} $params
87
     */
88
    public static function validationErrors(array $params = []): string
89
    {
90
        $validator = service('validation');
2✔
91
        if ($params === []) {
2✔
92
            return $validator->listErrors();
1✔
93
        }
94

95
        return $validator->showError($params['field']);
1✔
96
    }
97

98
    /**
99
     * Wrap helper function to use as view plugin.
100
     *
101
     * @param list<string> $params
102
     *
103
     * @return false|string
104
     */
105
    public static function route(array $params = [])
106
    {
107
        return route_to(...$params);
1✔
108
    }
109

110
    /**
111
     * Wrap helper function to use as view plugin.
112
     *
113
     * @param list<string> $params
114
     */
115
    public static function siteURL(array $params = []): string
116
    {
117
        return site_url(...$params);
1✔
118
    }
119

120
    /**
121
     * Wrap csp_script_nonce() function to use as view plugin.
122
     */
123
    public static function cspScriptNonce(): string
124
    {
125
        return csp_script_nonce();
1✔
126
    }
127

128
    /**
129
     * Wrap csp_style_nonce() function to use as view plugin.
130
     */
131
    public static function cspStyleNonce(): string
132
    {
UNCOV
133
        return csp_style_nonce();
×
134
    }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc