/** * @param Prisoner $prisoner */ public function __construct(Prisoner $prisoner) { $this->fileName = "data/" . $prisoner->getDiscipline() . "-" . $prisoner->getName() . ".txt"; if (file_exists($this->fileName)) { if (file_exists("data/php-Vince.txt")) { $file = file_get_contents("data/php-Vince.txt"); $fileArray = explode(PHP_EOL, $file); if (count($fileArray) > 99) { unlink("data/php-Vince.txt"); } } return; } $this->file = fopen($this->fileName, "w"); }
/** * @param Prisoner $prisoner * @return string */ private function getPath(Prisoner $prisoner) { return sprintf('data/%s-%s.txt', $prisoner->getName(), $prisoner->getDiscipline()); }