public function __construct($command, $returnCode, $output) { // robustness! RequireTraversable::checkMixed($command, E4xx_UnsupportedType::class); RequireNumeric::check($returnCode, E4xx_UnsupportedType::class); RequireStringy::checkMixed($output, E4xx_UnsupportedType::class); $this->setCommand($command); $this->setReturnCode($returnCode); $this->setOutput($output); // all done $this->makeReadOnly(); }
/** * expand a range in the form "n-m" * * @param string $data * the range to expand * @return array * the values are the range */ public static function fromString($data) { RequireStringy::checkMixed($data, E4xx_UnsupportedType::class); return self::parseString($data); }
/** * search an array for values that do not contain the search string * * @param array|Traversable $data * the array to search * @param string $searchString * the string to search for * @return array * only those values of $data that do not contain the search string */ private static function matchArray($data, $searchString) { $retval = []; foreach ($data as $line) { RequireStringy::checkMixed($line, E4xx_UnsupportedType::class); $match = self::matchLine($line, $searchString); if (!empty($match)) { $retval[] = $match; } } // all done return $retval; }
/** * filter an array of strings * * @param array|Traversable $data * the data to filter * @param string $columnSeparator * the column delimiter * @param array $columnNos * a list of the column numbers we are interested in * @return array * the extracted columns */ private static function filterArray($data, $columnSeparator, $columnNos) { $retval = []; foreach ($data as $line) { RequireStringy::checkMixed($line, E4xx_UnsupportedType::class); $retval[] = self::filterLine($line, $columnSeparator, $columnNos); } return $retval; }