/** * Get PSR-4 autoloader definitions. * * @param Module $module * @return mixed * @throws InvalidArgumentException */ protected function getPSR4Definition(Module $module) { $loaderArray = $module->toArray(); // Check psr-4 based definitions. if (!isset($loaderArray['autoload']['psr-4'])) { throw new InvalidArgumentException($module->directory); } return $loaderArray['autoload']['psr-4']; }
/** * Apply stub variables. * * @param $stub * @param Module $module * @param array $appends * @return string */ protected function applyStubVariables($stub, Module $module, array $appends = []) { $applyValues = array_merge($module->toArray(), $appends); $applyValues['NAMESPACE'] = [key($applyValues['autoload']['psr-4'])][0]; foreach ($applyValues as $key => $value) { if (is_string($value)) { $stub = str_replace('/*_' . strtoupper($key) . '_*/', $value, $stub); } } return $stub; }