/** * Get methods to render in item file * * @param StructureWithMethodsInterface $item * @param ReflectionClass $reflectionClass * @return ArrayCollection * @throws Exception */ protected function resolveMethodsToRender(StructureWithMethodsInterface $item, ReflectionClass $reflectionClass) { $methodsToRender = new ArrayCollection(); foreach ($item->getMethods() as $itemMethod) { if (false == $itemMethod instanceof MethodInterface) { throw new StructureResolverException(sprintf("Item %s does not implement Method Interface", get_class($itemMethod))); } $found = false; foreach ($reflectionClass->getMethods() as $reflectionMethod) { if ($itemMethod->getPreparedName() == $reflectionMethod->name) { $found = true; break; } } if (false == $found) { $methodsToRender->add($itemMethod); } } return $methodsToRender; }
/** * Output rendered methods * * @param OutputInterface $output * @param StructureWithMethodsInterface $item */ private function outputProcessMethods(OutputInterface $output, StructureWithMethodsInterface $item) { if ($item->getMethods()->isEmpty()) { $output->writeln('No methods to add'); } else { $output->writeln('<comment>methods:</comment>'); foreach ($item->getMethods() as $method) { $output->writeln(sprintf(" - %s", $method->getPreparedName())); } $output->writeln(''); } }