/** * @covers YAYOG\Parser::getExercise */ public function testGetExercise() { $method = $this->getMethod('getExercise'); $parsedExercise = $method->invoke($this->parser, '339,Tabatas,Beat Your Boots,Default,240,40,12'); $expectedExercise = new Exercise(); $expectedExercise->setNr(339)->setType('Tabatas')->setName('Beat Your Boots')->setVariation('Default')->setSeconds(240)->setReps(40); $this->assertEquals($expectedExercise, $parsedExercise); }
/** * Parses a single line of the log file, which contains one exercise. * * @param string $content Log file content for one exercise * @throws InvalidArgumentException If the string could not be converted to an exercise object * @return Exercise The exercise object created from the provided string */ protected function getExercise($content) { $parts = str_getcsv($content); if (count($parts) != 7) { throw new InvalidArgumentException('Could not convert string to an exercise object'); } $exercise = new Exercise(); $exercise->setNr($parts[0])->setType($parts[1])->setName($parts[2])->setVariation($parts[3])->setSeconds($parts[4])->setReps($parts[5]); return $exercise; }