@@ -227,6 +227,9 @@ discard block |
||
| 227 | 227 | return new self($this->raw{$offset}); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | + /** |
|
| 231 | + * @param integer $offset |
|
| 232 | + */ |
|
| 230 | 233 | public function charCodeAt($offset) |
| 231 | 234 | { |
| 232 | 235 | if ($this->encoding === self::WINDOWS1252) { |
@@ -354,6 +357,9 @@ discard block |
||
| 354 | 357 | return new self(\str_repeat($this->raw, $times)); |
| 355 | 358 | } |
| 356 | 359 | |
| 360 | + /** |
|
| 361 | + * @param string $replace |
|
| 362 | + */ |
|
| 357 | 363 | public function replace($search, $replace, $mode = self::NORMAL) |
| 358 | 364 | { |
| 359 | 365 | if ($mode & self::CASE_INSENSITIVE) { |
@@ -686,6 +692,9 @@ discard block |
||
| 686 | 692 | return [$offset, 1, false, $byte]; |
| 687 | 693 | } |
| 688 | 694 | |
| 695 | + /** |
|
| 696 | + * @param integer $byte |
|
| 697 | + */ |
|
| 689 | 698 | protected static function calcUtf8CharLength($byte) |
| 690 | 699 | { |
| 691 | 700 | if (~$byte & 0b00001000) return 4; |
@@ -591,13 +591,9 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | if ($length === 2) { |
| 593 | 593 | $bigcode = $byte & 0b00011111; |
| 594 | - } |
|
| 595 | - |
|
| 596 | - elseif ($length === 3) { |
|
| 594 | + } elseif ($length === 3) { |
|
| 597 | 595 | $bigcode = $byte & 0b00001111; |
| 598 | - } |
|
| 599 | - |
|
| 600 | - elseif ($length === 4) { |
|
| 596 | + } elseif ($length === 4) { |
|
| 601 | 597 | $bigcode = $byte & 0b00000111; |
| 602 | 598 | } |
| 603 | 599 | |
@@ -688,9 +684,15 @@ discard block |
||
| 688 | 684 | |
| 689 | 685 | protected static function calcUtf8CharLength($byte) |
| 690 | 686 | { |
| 691 | - if (~$byte & 0b00001000) return 4; |
|
| 692 | - if (~$byte & 0b00010000) return 3; |
|
| 693 | - if (~$byte & 0b00100000) return 2; |
|
| 687 | + if (~$byte & 0b00001000) { |
|
| 688 | + return 4; |
|
| 689 | + } |
|
| 690 | + if (~$byte & 0b00010000) { |
|
| 691 | + return 3; |
|
| 692 | + } |
|
| 693 | + if (~$byte & 0b00100000) { |
|
| 694 | + return 2; |
|
| 695 | + } |
|
| 694 | 696 | return 1; |
| 695 | 697 | } |
| 696 | 698 | } |