Пример #1
0
 public function testSave()
 {
     $downstream = new Downstream();
     $downstream->setChannelId(3)->setFrequency(1500100900)->setSnr(40.2);
     $downstreams = new ArrayCollection();
     $downstreams->add($downstream);
     $this->parserMock->method('parse')->willReturn($downstreams);
     $this->entityManagerMock->method('persist')->with($downstream);
     $this->entityManagerMock->method('flush');
 }
Пример #2
0
 /**
  * @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;
 }