PhpOffice\PhpPresentation\HashTable::getByIndex PHP Метод

getByIndex() публичный Метод

Get by index
public getByIndex ( integer $pIndex ) : PhpOffice\PhpPresentation\ComparableInterface
$pIndex integer
Результат PhpOffice\PhpPresentation\ComparableInterface
    public function getByIndex($pIndex = 0)
    {
        if (isset($this->keyMap[$pIndex])) {
            return $this->getByHashCode($this->keyMap[$pIndex]);
        }
        return null;
    }

Usage Example

Пример #1
0
 /**
  */
 public function testIndex()
 {
     $object = new HashTable();
     $oSlide1 = new Slide();
     $oSlide2 = new Slide();
     // Add Object
     $this->assertNull($object->add($oSlide1));
     $this->assertNull($object->add($oSlide2));
     // Index
     $this->assertEquals(0, $object->getIndexForHashCode($oSlide1->getHashCode()));
     $this->assertEquals(1, $object->getIndexForHashCode($oSlide2->getHashCode()));
     $this->assertEquals($oSlide1, $object->getByIndex(0));
     $this->assertEquals($oSlide2, $object->getByIndex(1));
 }