setName('interface:validate')
->setDescription('Validates an interface for the phpMAE.')
->addArgument('coid', InputArgument::REQUIRED, 'The COID of the object.')
->addOption('watch', null, InputOption::VALUE_OPTIONAL, 'Keep watching for changes of the file and revalidate automatically.', null);
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->parse($input->getArgument('coid'));
$this->assertRDF();
if (!in_array('coid://phpmae.dev/Interface', $this->rdfTypes))
throw new \Exception("Object does not have the valid interface type.");
$this->assertPHPExists();
// Running validator
$validator = new ClassValidator;
try {
$validator->validateInterface(file_get_contents($this->phpFileName), $this->coid);
$output->writeln("Validated successfully.");
} catch (\Exception $e) {
$output->writeln(''.get_class($e).' '.$e->getMessage());
}
if ($input->getOption('watch') !== null) {
$cmd = $this;
$this->watchPHPFile($output, function() use ($validator, $cmd, $output) {
try {
$validator->validateInterface(file_get_contents($cmd->phpFileName), $this->coid);
$output->writeln("Validated successfully.");
} catch (\Exception $e) {
$output->writeln(''.get_class($e).' '.$e->getMessage());
}
});
}
}
}