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

voku / portable-utf8 / 17838117016

18 Sep 2025 06:35PM UTC coverage: 82.256% (+0.6%) from 81.683%
17838117016

Pull #223

github

web-flow
Merge 6c9957219 into c4b377468
Pull Request #223: Update shivammathur/setup-php action to v2.35.5

3361 of 4086 relevant lines covered (82.26%)

78.62 hits per line

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

76.19
/src/voku/helper/Bootup.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace voku\helper;
6

7
class Bootup
8
{
9
    /**
10
     * Normalizes to UTF-8 NFC, converting from WINDOWS-1252 when needed.
11
     *
12
     * @param mixed  $input
13
     * @param int    $normalization_form
14
     * @param string $leading_combining
15
     *
16
     * @return mixed
17
     */
18
    public static function filterString(
19
        $input,
20
        int $normalization_form = \Normalizer::NFC,
21
        string $leading_combining = '◌'
22
    ) {
23
        return UTF8::filter(
×
24
            $input,
×
25
            $normalization_form,
×
26
            $leading_combining
×
27
        );
28
    }
29

30
    /**
31
     * Get random bytes via "random_bytes()"
32
     *
33
     * @param int $length <p>output length</p>
34
     *
35
     * @throws \Exception if it was not possible to gather sufficient entropy
36
     *
37
     * @return false|string
38
     *                      <strong>false</strong> on error
39
     */
40
    public static function get_random_bytes($length)
41
    {
42
        if (!$length) {
8✔
43
            return false;
8✔
44
        }
45

46
        $length = (int) $length;
8✔
47

48
        if ($length <= 0) {
8✔
49
            return false;
8✔
50
        }
51

52
        return \random_bytes($length);
8✔
53
    }
54

55
    /**
56
     * Constant FILTER_SANITIZE_STRING polyfill for PHP > 8.1
57
     *
58
     * INFO: https://stackoverflow.com/a/69207369/1155858
59
     *
60
     * @param string $str
61
     *
62
     * @return false|string
63
     */
64
    public static function filter_sanitize_string_polyfill(string $str)
65
    {
66
        $str = \preg_replace('/\x00|<[^>]*>?/', '', $str);
96✔
67
        if ($str === null) {
96✔
68
            return false;
×
69
        }
70

71
        return \str_replace(["'", '"'], ['&#39;', '&#34;'], $str);
96✔
72
    }
73

74
    /**
75
     * @return bool
76
     */
77
    public static function initAll(): bool
78
    {
79
        $result = \ini_set('default_charset', 'UTF-8');
8✔
80

81
        // everything else is init via composer, so we are done here ...
82

83
        return $result !== false;
8✔
84
    }
85

86
    /**
87
     * Determines if the current version of PHP is equal to or greater than the supplied value.
88
     *
89
     * @param string $version <p>e.g. "7.1"<p>
90
     *
91
     * @return bool
92
     *              <p>Return <strong>true</strong> if the current version is $version or greater.</p>
93
     *
94
     * @psalm-pure
95
     */
96
    public static function is_php($version): bool
97
    {
98
        /**
99
         * @psalm-suppress ImpureStaticVariable
100
         *
101
         * @var bool[]
102
         */
103
        static $_IS_PHP;
264✔
104

105
        $version = (string) $version;
264✔
106

107
        if (!isset($_IS_PHP[$version])) {
264✔
108
            $_IS_PHP[$version] = \version_compare(\PHP_VERSION, $version, '>=');
32✔
109
        }
110

111
        return $_IS_PHP[$version];
264✔
112
    }
113
}
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

© 2025 Coveralls, Inc