/** * @param string $path */ public function generateFromNeonFile($path) { $definition = Neon::decode(file_get_contents($path)); assert(isset($definition['class'])); assert(isset($definition['type'])); assert($definition['type'] === 'in-place'); $data = $definition['data']; $output = $this->configuration->getDir() . DIRECTORY_SEPARATOR . $this->configuration->getOutputFolder() . DIRECTORY_SEPARATOR . $definition['class'] . '.php'; $consts = Helper::createStringConstants($data); $node = $this->createClassFromData($definition['class'], $this->configuration->getNamespace(), $consts); $prettyPrinter = new PrettyPrinter\Standard(); file_put_contents($output, $prettyPrinter->prettyPrintFile([$node])); }
/** * * @param $className * @param null $addFolder * * @return string */ private function getOutputPath($className, $addFolder = null) { if ($addFolder !== null) { $output = implode(DIRECTORY_SEPARATOR, [$this->configuration->getDir(), $this->configuration->getOutputFolder(), $addFolder, $className . '.php']); return $output; } else { $output = implode(DIRECTORY_SEPARATOR, [$this->configuration->getDir(), $this->configuration->getOutputFolder(), $className . '.php']); return $output; } }