/** * @param string $inputString * * @return ArrayCollection */ public function parse($inputString) { $begin = strpos($inputString, '<tbody>'); $tableBodyString = substr($inputString, $begin, strpos($inputString, '</tbody>') - $begin); $downstreams = new ArrayCollection(); $rows = preg_split('#</tr>\\s+?<tr>#', $tableBodyString); $now = new \DateTime(); foreach ($rows as $row) { $downstreamArray = preg_split('#</td>\\s+?<td>#', $row); $downstream = new Downstream(); $downstream->setReceiverNo($this->matchNumber($downstreamArray[0], 'Receiver No.')); $downstream->setChannelId($this->matchNumber($downstreamArray[1], 'Channel Id')); $downstream->setLockStatus($this->matchString($downstreamArray[2], 'Lock status')); $downstream->setFrequency($this->matchNumber($downstreamArray[3], 'Frequency')); $downstream->setModulation($this->matchString($downstreamArray[4], 'Modulation')); $downstream->setSymbolRate($this->matchString($downstreamArray[5], 'SymbolRate')); $downstream->setSnr($this->matchFloat($downstreamArray[6], 'Snr')); $downstream->setPower($this->matchFloat($downstreamArray[7], 'Power')); $downstream->setDateTime($now); $downstreams->add($downstream); } return $downstreams; }