<?php
class inputManager{
private $index = 0;
private $input = [];
const SPRIT_STR = " ";
@access
@param
@return
public function __construct($testFlg = false, $testInput = null){
if(!$testFlg){
$input_lines = trim(fgets(STDIN));
$input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
do {
$this->input[] = $input_lines;
$input_lines = trim(fgets(STDIN));
$input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
} while ($input_lines !== "");
}else{
$this->input = $testInput;
}
}
@access
@param
@return
public function value(){
if($this->index < $this->length()){
return $this->input[$this->index];
}else{
return null;
}
}
@access
@param
@return
public function explodeValue(){
if($this->index < $this->length()){
return explode(self::SPRIT_STR, $this->input[$this->index]);
}else{
return null;
}
}
@access
@param
@return
public function setindex(int $i_index){
$this->index = $i_index;
return $this;
}
@access
@param
@return
public function next(){
$this->index++;
return $this;
}
@access
@param
@return
public function length(){
return count($this->input);
}
}
class out{
@access
@param
@return
public static function output(string $i_val = ""){
echo $i_val. "\n";
}
}
$input[] = "123";
$input[] = "456";
$input[] = "789";
$input[] = "aaa";
$input[] = "bbb";
$io = new inputManager(true,$input);
out::output($io->length());
out::output();
out::output($io->value());
$io->next();
out::output($io->value());
$io->setindex(2);
out::output($io->value());
out::output($io->next()->value());
out::output($io->next()->value());
out::output();
$io->setindex(0);
while(!is_null($io->value())){
out::output($io->value());
$io->next();
}
out::output();
for($i = 0;$i < $io->length(); $i++){
out::output($io->setindex($i)->value());
}