1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Polyfill\Util;
13
14/**
15 * Binary safe version of string functions overloaded when MB_OVERLOAD_STRING is enabled.
16 *
17 * @author Nicolas Grekas <p@tchwork.com>
18 *
19 * @internal
20 */
21class BinaryOnFuncOverload
22{
23    public static function strlen($s)
24    {
25        return mb_strlen($s, '8bit');
26    }
27
28    public static function strpos($haystack, $needle, $offset = 0)
29    {
30        return mb_strpos($haystack, $needle, $offset, '8bit');
31    }
32
33    public static function strrpos($haystack, $needle, $offset = 0)
34    {
35        return mb_strrpos($haystack, $needle, $offset, '8bit');
36    }
37
38    public static function substr($string, $start, $length = 2147483647)
39    {
40        return mb_substr($string, $start, $length, '8bit');
41    }
42
43    public static function stripos($s, $needle, $offset = 0)
44    {
45        return mb_stripos($s, $needle, $offset, '8bit');
46    }
47
48    public static function stristr($s, $needle, $part = false)
49    {
50        return mb_stristr($s, $needle, $part, '8bit');
51    }
52
53    public static function strrchr($s, $needle, $part = false)
54    {
55        return mb_strrchr($s, $needle, $part, '8bit');
56    }
57
58    public static function strripos($s, $needle, $offset = 0)
59    {
60        return mb_strripos($s, $needle, $offset, '8bit');
61    }
62
63    public static function strstr($s, $needle, $part = false)
64    {
65        return mb_strstr($s, $needle, $part, '8bit');
66    }
67}
68