@@ -597,6 +597,37 @@ public static function provideSlice()
597
597
['awesome ' , 'Symfony is awesome ' , 11 , 7 ],
598
598
['awesome ' , 'Symfony is awesome ' , -7 , null ],
599
599
['awe ' , 'Symfony is awesome ' , -7 , -4 ],
600
+ ['S ' , 'Symfony is awesome ' , -42 , 1 ],
601
+ ['' , 'Symfony is awesome ' , 42 , 1 ],
602
+ ['' , 'Symfony is awesome ' , 0 , -42 ],
603
+ ];
604
+ }
605
+
606
+ /**
607
+ * @dataProvider provideSplice
608
+ */
609
+ public function testSplice (string $ expected , int $ start , int $ length = null )
610
+ {
611
+ $ this ->assertEquals (
612
+ static ::createFromString ($ expected ),
613
+ static ::createFromString ('Symfony is awesome ' )->splice ('X ' , $ start , $ length )
614
+ );
615
+ }
616
+
617
+ public static function provideSplice ()
618
+ {
619
+ return [
620
+ ['X is awesome ' , 0 , 7 ],
621
+ ['SymfonyXis awesome ' , 7 , 1 ],
622
+ ['Symfony X awesome ' , 8 , 2 ],
623
+ ['Symfony X ' , 8 , null ],
624
+ ['Symfony isXawesome ' , 10 , 1 ],
625
+ ['Symfony is X ' , 11 , 7 ],
626
+ ['Symfony is X ' , -7 , null ],
627
+ ['Symfony is Xsome ' , -7 , -4 ],
628
+ ['Xymfony is awesome ' , -42 , 1 ],
629
+ ['Symfony is awesomeX ' , 42 , 1 ],
630
+ ['XSymfony is awesome ' , 0 , -42 ],
600
631
];
601
632
}
602
633
@@ -766,12 +797,12 @@ public function testBeforeAfter(string $expected, string $needle, string $origin
766
797
public static function provideBeforeAfter ()
767
798
{
768
799
return [
769
- ['' , '' , 'hello world ' , 0 , true ],
770
- ['' , '' , 'hello world ' , 0 , false ],
771
- ['' , 'w ' , 'hello World ' , 0 , true ],
772
- ['' , 'w ' , 'hello World ' , 0 , false ],
773
- ['' , 'o ' , 'hello world ' , 10 , true ],
774
- ['' , 'o ' , 'hello world ' , 10 , false ],
800
+ ['hello world ' , '' , 'hello world ' , 0 , true ],
801
+ ['hello world ' , '' , 'hello world ' , 0 , false ],
802
+ ['hello World ' , 'w ' , 'hello World ' , 0 , true ],
803
+ ['hello World ' , 'w ' , 'hello World ' , 0 , false ],
804
+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
805
+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
775
806
['hello ' , 'w ' , 'hello world ' , 0 , true ],
776
807
['world ' , 'w ' , 'hello world ' , 0 , false ],
777
808
['hello W ' , 'O ' , 'hello WORLD ' , 0 , true ],
@@ -794,12 +825,12 @@ public function testBeforeAfterIgnoreCase(string $expected, string $needle, stri
794
825
public static function provideBeforeAfterIgnoreCase ()
795
826
{
796
827
return [
797
- ['' , '' , 'hello world ' , 0 , true ],
798
- ['' , '' , 'hello world ' , 0 , false ],
799
- ['' , 'foo ' , 'hello world ' , 0 , true ],
800
- ['' , 'foo ' , 'hello world ' , 0 , false ],
801
- ['' , 'o ' , 'hello world ' , 10 , true ],
802
- ['' , 'o ' , 'hello world ' , 10 , false ],
828
+ ['hello world ' , '' , 'hello world ' , 0 , true ],
829
+ ['hello world ' , '' , 'hello world ' , 0 , false ],
830
+ ['hello world ' , 'foo ' , 'hello world ' , 0 , true ],
831
+ ['hello world ' , 'foo ' , 'hello world ' , 0 , false ],
832
+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
833
+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
803
834
['hello ' , 'w ' , 'hello world ' , 0 , true ],
804
835
['world ' , 'w ' , 'hello world ' , 0 , false ],
805
836
['hello ' , 'W ' , 'hello world ' , 0 , true ],
@@ -822,12 +853,12 @@ public function testBeforeAfterLast(string $expected, string $needle, string $or
822
853
public static function provideBeforeAfterLast ()
823
854
{
824
855
return [
825
- ['' , '' , 'hello world ' , 0 , true ],
826
- ['' , '' , 'hello world ' , 0 , false ],
827
- ['' , 'L ' , 'hello world ' , 0 , true ],
828
- ['' , 'L ' , 'hello world ' , 0 , false ],
829
- ['' , 'o ' , 'hello world ' , 10 , true ],
830
- ['' , 'o ' , 'hello world ' , 10 , false ],
856
+ ['hello world ' , '' , 'hello world ' , 0 , true ],
857
+ ['hello world ' , '' , 'hello world ' , 0 , false ],
858
+ ['hello world ' , 'L ' , 'hello world ' , 0 , true ],
859
+ ['hello world ' , 'L ' , 'hello world ' , 0 , false ],
860
+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
861
+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
831
862
['hello wor ' , 'l ' , 'hello world ' , 0 , true ],
832
863
['ld ' , 'l ' , 'hello world ' , 0 , false ],
833
864
['hello w ' , 'o ' , 'hello world ' , 0 , true ],
@@ -851,12 +882,12 @@ public function testBeforeAfterLastIgnoreCase(string $expected, string $needle,
851
882
public static function provideBeforeAfterLastIgnoreCase ()
852
883
{
853
884
return [
854
- ['' , '' , 'hello world ' , 0 , true ],
855
- ['' , '' , 'hello world ' , 0 , false ],
856
- ['' , 'FOO ' , 'hello world ' , 0 , true ],
857
- ['' , 'FOO ' , 'hello world ' , 0 , false ],
858
- ['' , 'o ' , 'hello world ' , 10 , true ],
859
- ['' , 'o ' , 'hello world ' , 10 , false ],
885
+ ['hello world ' , '' , 'hello world ' , 0 , true ],
886
+ ['hello world ' , '' , 'hello world ' , 0 , false ],
887
+ ['hello world ' , 'FOO ' , 'hello world ' , 0 , true ],
888
+ ['hello world ' , 'FOO ' , 'hello world ' , 0 , false ],
889
+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
890
+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
860
891
['hello wor ' , 'l ' , 'hello world ' , 0 , true ],
861
892
['ld ' , 'l ' , 'hello world ' , 0 , false ],
862
893
['hello wor ' , 'L ' , 'hello world ' , 0 , true ],
0 commit comments