| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Spiral\Scaffolder\Config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Inflector\Rules\English\InflectorFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Spiral\Core\InjectableConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Spiral\Scaffolder\Exception\ScaffolderException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Configuration for default scaffolder namespaces and other rendering options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | class ScaffolderConfig extends InjectableConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     public const CONFIG = 'scaffolder'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     protected array $config = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         'header' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         'directory' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         'namespace' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         'declarations' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         'defaults' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             'declarations' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 34 |  |     public function headerLines(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 34 |  |         return $this->config['header']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @deprecated since v3.8.0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function baseDirectory(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         return $this->config['directory']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @return non-empty-string[] | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 | 48 |  |     public function getDeclarations(): array | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 46 | 48 |  |         return \array_keys($this->config['defaults']['declarations'] ?? []) + \array_keys( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             $this->config['declarations'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 48 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 38 |  |     public function declarationDirectory(string $element): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 38 |  |         $declaration = $this->getDeclaration($element); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 38 |  |         return !empty($declaration['directory']) ? $declaration['directory'] : $this->config['directory']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 38 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 38 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function className(string $element, string $name): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         ['name' => $name] = $this->parseName($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 26 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $class = $this->classify($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 26 |  |         $postfix = $this->elementPostfix($element); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 26 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return \str_ends_with($class, $postfix) ? $class : $class . $postfix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 26 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 26 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function classNamespace(string $element, string $name = ''): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $localNamespace = \trim($this->getOption($element, 'namespace', ''), '\\'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 26 |  |         ['namespace' => $namespace] = $this->parseName($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         if (!empty($namespace)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             $localNamespace .= '\\' . $this->classify($namespace); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         if (empty($this->baseNamespace($element))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             return $localNamespace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 38 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         return \trim($this->baseNamespace($element) . '\\' . $localNamespace, '\\'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 38 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 38 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 38 |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 38 |  |      * @param non-empty-string $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 38 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 38 |  |      * @return non-empty-string | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 38 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     public function classFilename(string $element, string $name, ?string $namespace = null): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $elementNamespace = $namespace ?? $this->classNamespace($element, $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $elementNamespace = \substr($elementNamespace, \strlen($this->baseNamespace($element))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return $this->joinPathChunks([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             $this->declarationDirectory($element), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             \str_replace('\\', '/', $elementNamespace), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $this->className($element, $name) . '.php', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         ], '/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @throws ScaffolderException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     public function declarationClass(string $element): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $class = $this->getOption($element, 'class'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         if (empty($class)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             throw new ScaffolderException( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                 \sprintf("Unable to scaffold '%s', no declaration class found", $element), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 37 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 37 |  |         return $class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * Declaration options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 38 |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 38 |  |     public function declarationOptions(string $element): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         return $this->getOption($element, 'options', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * Get declaration options by element name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 45 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 45 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     public function getDeclaration(string $element): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 45 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 1 |  |         $default = $this->config['defaults']['declarations'][$element] ?? []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $declaration = $this->config['declarations'][$element] ?? []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 | 44 |  |         return $declaration + $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 40 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 30 |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     private function elementPostfix(string $element): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return $this->getOption($element, 'postfix', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * @param non-empty-string $section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 38 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     private function getOption(string $element, string $section, mixed $default = null): mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 38 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $declaration = $this->getDeclaration($element); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 38 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 1 |  |         if ($declaration === []) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 | 1 |  |             throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         if (\array_key_exists($section, $declaration)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             return $declaration[$section]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 37 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * Split user name into namespace and class name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 40 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @param non-empty-string $name | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 | 40 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @return array{namespace: string, name: non-empty-string} | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 40 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 1 |  |     private function parseName(string $name): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $name = \str_replace('/', '\\', $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 39 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         if (str_contains($name, '\\')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             $names = \explode('\\', $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 38 |  |             $class = \array_pop($names); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 38 |  |             return ['namespace' => \implode('\\', $names), 'name' => $class]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 38 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 38 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 38 |  |         //No user namespace | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 38 |  |         return ['namespace' => '', 'name' => $name]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 38 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 38 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      * @param non-empty-string $element | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     private function baseNamespace(string $element): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 38 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $declaration = $this->getDeclaration($element); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 38 |  |         if (\array_key_exists('baseNamespace', $declaration)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 38 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 38 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 | 38 |  |         return \trim($this->config['namespace'], '\\'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     private function joinPathChunks(array $chunks, string $joint): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $firstChunkIterated = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 | 56 |  |         $joinedPath = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         foreach ($chunks as $chunk) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 56 |  |             if (!$firstChunkIterated) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 56 |  |                 $firstChunkIterated = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                 $joinedPath = $chunk; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 56 |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 $joinedPath = \rtrim($joinedPath, $joint) . $joint . \ltrim($chunk, $joint); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         return $joinedPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     private function classify(string $name): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         return (new InflectorFactory()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             ->build() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             ->classify($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 237 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 238 |  |  |  |