input = $input; $this->output = $output; $this->autoClose = $autoClose; $this->context = $this; } protected function ensureInput(): IReader { $input = $this->input; if ($input === null) { $input = $this->INPUT(); if ($input === null) { throw new ValueException("input is required"); } $input = new FileReader($input); } return $input; } /** retourner true */ function apply() { $context = $this->getContext(); $input = $this->ensureInput(); $output = $this->output; foreach ($input as $line) { $line = $this->applyRules($line, $context); $output->wnl($line); } $output->close($this->autoClose); return true; } }