Ejemplo n.º 1
0
 /**
  * Takes raw API data and converts into a result
  *
  * @param array $data
  * @return Result
  */
 public function create($data)
 {
     $result = new Result();
     $rows = [];
     foreach ($data as $row) {
         $rows[] = $this->rowFactory->create($row);
     }
     $result->setRows($rows);
     return $result;
 }
Ejemplo n.º 2
0
 /**
  *  Test array access to result object
  */
 public function testArrayAccess()
 {
     $rows = [$this->getMock('Silktide\\SemRushApi\\Model\\Row'), $this->getMock('Silktide\\SemRushApi\\Model\\Row'), $this->getMock('Silktide\\SemRushApi\\Model\\Row')];
     foreach ($rows as $index => $row) {
         $this->instance[$index] = $row;
     }
     $this->assertTrue(isset($this->instance[0]));
     $this->assertFalse(isset($this->instance[9]));
     $this->assertEquals($rows[1], $this->instance[1]);
     unset($this->instance[1]);
     $this->assertEquals(2, count($this->instance));
     $result = $this->instance->toArray();
     $this->assertEquals(2, count($result));
 }