| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Inflector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Inflector\Rules\English\Plural; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\Inflector\Rules\English\Singular; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Doctrine\Inflector\Rules\Irregular; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Doctrine\Inflector\Rules\Ruleset; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Doctrine\Inflector\Rules\Transformations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Doctrine\Inflector\Rules\Uninflected; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | final class SingularizerFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     /** @var Transformations */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     private $transformations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** @var Uninflected */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $uninflected; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** @var Irregular */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     private $irregular; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** @var Irregular */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $pluralIrregular; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 2 |  |     public function withTransformations(Transformations $transformations) : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 2 |  |         $this->transformations = $transformations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 2 |  |     public function withUninflected(Uninflected $uninflected) : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 2 |  |         $this->uninflected = $uninflected; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 42 | 2 |  |     public function withIrregular(Irregular $irregular) : self | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 | 2 |  |         $this->irregular = $irregular; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function withPluralIrregular(Irregular $pluralIrregular) : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->pluralIrregular = $pluralIrregular; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 525 |  |     public function build() : Ruleset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 525 |  |         $transformations = $this->transformations ?? new Transformations(...Singular::getTransformations()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 525 |  |         $uninflected     = $this->uninflected ?? new Uninflected(...Singular::getUninflected()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 525 |  |         $irregular       = $this->irregular ?? new Irregular(...Singular::getIrregular()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 525 |  |         $pluralIrregular = $this->pluralIrregular ?? new Irregular(...Plural::getIrregular()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $singularUninflected = new Uninflected(...(static function () use ($uninflected) : iterable { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 525 |  |             yield from $uninflected->getPatterns(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 525 |  |             yield from Uninflected::getDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 525 |  |         })()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $singularIrregular = new Irregular(...(static function () use ($irregular, $pluralIrregular) : iterable { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 525 |  |             yield from $irregular->getSubstitutions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 525 |  |             yield from $pluralIrregular->getFlippedSubstitutions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 525 |  |         })()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 525 |  |         return new Ruleset($transformations, $singularUninflected, $singularIrregular); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 75 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |  |