/** * @param string $regex * * @return string * @throws InvalidRegexException */ public function generate($regex) { $expr = substr($regex, 1, -1); try { $result = RegRev::generate($expr); } catch (\Exception $e) { throw new InvalidRegexException($expr); } return $result; }
/** * @param string $regex * * @return string * @throws InvalidRegexException */ public function generate($regex) { $expr = substr($regex, 1, -1); $result = RegRev::generate($expr); if ($result !== null) { return $result; } else { throw new InvalidRegexException($expr); } }
/** * {@inheritdoc} */ public function generate() { return RegRev::generate(substr($this->getMatch(), 1, -1)); }
<?php require 'vendor/autoload.php'; use RegRev\RegRev; echo RegRev::generate($argv[1]); //ouput a random number echo "\n";