mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	Fix ExtractPhonenumberFromPattern to retain original subject in SearchExtractionResult
				
					
				
			- Updated logic in `ExtractPhonenumberFromPattern` to ensure the original subject is preserved in the resulting extraction. - Adjusted test cases in `ExtractPhonenumberFromPatternTest` to reflect the updated behavior.
This commit is contained in:
		@@ -80,9 +80,7 @@ class ExtractPhonenumberFromPattern
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (5 < $length) {
 | 
			
		||||
                $filtered = \trim(\strtr($subject, [$matches[0] => '']));
 | 
			
		||||
 | 
			
		||||
                return new SearchExtractionResult($filtered, [\implode('', $phonenumber)]);
 | 
			
		||||
                return new SearchExtractionResult($subject, [\implode('', $phonenumber)]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -43,20 +43,20 @@ final class ExtractPhonenumberFromPatternTest extends KernelTestCase
 | 
			
		||||
 | 
			
		||||
        yield ['BE', 'Diallo 15/06/2021', 0, [], 'Diallo 15/06/2021', 'no phonenumber and a date'];
 | 
			
		||||
 | 
			
		||||
        yield ['BE', 'Diallo 0486 123 456', 1, ['+32486123456'], 'Diallo', 'a phonenumber and a name'];
 | 
			
		||||
        yield ['BE', 'Diallo 0486 123 456', 1, ['+32486123456'], 'Diallo 0486 123 456', 'a phonenumber and a name'];
 | 
			
		||||
 | 
			
		||||
        yield ['BE', 'Diallo 123 456', 1, ['123456'], 'Diallo', 'a number and a name, without leadiing 0'];
 | 
			
		||||
        yield ['BE', 'Diallo 123 456', 1, ['123456'], 'Diallo 123 456', 'a number and a name, without leadiing 0'];
 | 
			
		||||
 | 
			
		||||
        yield ['BE', '123 456', 1, ['123456'], '', 'only phonenumber'];
 | 
			
		||||
        yield ['BE', '123 456', 1, ['123456'], '123 456', 'only phonenumber'];
 | 
			
		||||
 | 
			
		||||
        yield ['BE', '0123 456', 1, ['+32123456'], '', 'only phonenumber with a leading 0'];
 | 
			
		||||
        yield ['BE', '0123 456', 1, ['+32123456'], '0123 456', 'only phonenumber with a leading 0'];
 | 
			
		||||
 | 
			
		||||
        yield ['FR', '123 456', 1, ['123456'], '', 'only phonenumber'];
 | 
			
		||||
        yield ['FR', '123 456', 1, ['123456'], '123 456', 'only phonenumber'];
 | 
			
		||||
 | 
			
		||||
        yield ['FR', '0123 456', 1, ['+33123456'], '', 'only phonenumber with a leading 0'];
 | 
			
		||||
        yield ['FR', '0123 456', 1, ['+33123456'], '0123 456', 'only phonenumber with a leading 0'];
 | 
			
		||||
 | 
			
		||||
        yield ['FR', 'Diallo 0486 123 456', 1, ['+33486123456'], 'Diallo', 'a phonenumber and a name'];
 | 
			
		||||
        yield ['FR', 'Diallo 0486 123 456', 1, ['+33486123456'], 'Diallo 0486 123 456', 'a phonenumber and a name'];
 | 
			
		||||
 | 
			
		||||
        yield ['FR', 'Diallo +32486 123 456', 1, ['+32486123456'], 'Diallo', 'a phonenumber and a name'];
 | 
			
		||||
        yield ['FR', 'Diallo +32486 123 456', 1, ['+32486123456'], 'Diallo +32486 123 456', 'a phonenumber and a name'];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user