protected function execute(InputInterface $input, OutputInterface $output) { $inputSource = $input->getOption('input'); $size = (int) $input->getOption('size'); if ($size < 1 || $size > 2000) { $output->writeln('<error>Sample size must be a positive integer between 1 and 2000.</error>'); return; } // Input size should be 10 times the size of the sample $streamSize = $size * 10; switch ($inputSource) { case 'stdin': $stream = new StreamIterator(); break; case 'random.org': $stream = new RandomOrgIterator($this->httpClient); $stream->setLength($streamSize); break; case 'internal': $stream = new RandomByteIterator(); $stream->setLength($streamSize); break; default: $output->writeln('<error>Unknown input source: "' . $inputSource . '". Use either stdin, random.org or internal.</error>'); return; } $this->sampler->setStream($stream); $result = $this->sampler->getSampleAsString($size); $output->writeln($result); }
public function testSetLength() { $this->input->setLength(591); $this->assertEquals(591, $this->input->getLength()); }