estimatorService = $estimatorService; $this->addArgument( 'uid', InputArgument::REQUIRED, 'the UID of the user to run a prediction for' ); $this->addArgument( 'ip', InputArgument::REQUIRED, 'the IP to predict suspiciousness' ); $this->addArgument( 'model', InputArgument::OPTIONAL, 'persisted model id (latest if omited)' ); $this->addOption( 'v6', null, InputOption::VALUE_NONE, 'train with IPv6 data' ); } protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); $ip = $input->getArgument('ip'); $modelId = $input->getArgument('model'); try { if (!$this->estimatorService->predict( $uid, $ip, $input->getOption('v6') ? new IpV6Strategy() : new Ipv4Strategy(), $modelId ? (int)$modelId : null)) { $output->writeln("WARN: IP $ip is suspicious"); return 1; } } catch (ModelNotFoundException $ex) { $output->writeln('Could not predict suspiciousness: ' . $ex->getMessage() . ''); return 2; } catch (ServiceException $ex) { $output->writeln('Could not predict suspiciousness: ' . $ex->getMessage() . ''); return 3; } $output->writeln("OK: IP $ip is not suspicious"); return 0; } }