/** * 推出准备好的正品,否则推出替代品 */ public static function mock(&$inner = null) { $obj = new self($inner); return $obj->isReady() ? $obj->inner : $obj; }
/** * This method provides a declaratory means of reading a string. * * @access public * @static * @param string $string the data source to be used * @param callable $callback the callback function that will * handle the read * @param string $mode the mode in which to read the file * @throws Throwable\InvalidArgument\Exception indicates an invalid argument specified * @throws \Exception indicates a rethrown exception */ public static function read($string, $callback, $mode = 'readLine') { if (!in_array($mode, array('readChar', 'readLine', 'readToEnd'))) { throw new Throwable\InvalidArgument\Exception('Invalid argument specified. Expected mode to be either "read", "readLine", or "readToEnd", but got :mode.', array(':mode' => $mode)); } $reader = null; try { $reader = new self($string); for ($index = 0; $reader->isReady(); $index++) { $callback($reader, $reader->{$mode}(), $index); } $reader->close(); } catch (\Exception $ex) { if ($reader != null) { $reader->close(); } throw $ex; } }
static function mock(&$pC = null) { $OB = new self($pC); return $OB->isReady() ? $OB->inner : $OB; }