PhpOffice\PhpPresentation\PhpPresentation::getIndex PHP Method

getIndex() public method

Get index for slide
public getIndex ( AbstractSlide $slide ) : integer
$slide PhpOffice\PhpPresentation\Slide\AbstractSlide
return integer
    public function getIndex(Slide\AbstractSlide $slide)
    {
        $index = null;
        foreach ($this->slideCollection as $key => $value) {
            if ($value->getHashCode() == $slide->getHashCode()) {
                $index = $key;
                break;
            }
        }
        return $index;
    }

Usage Example

 /**
  * Test create new instance
  */
 public function testConstruct()
 {
     $object = new PhpPresentation();
     $slide = $object->getSlide();
     $this->assertEquals(new DocumentProperties(), $object->getDocumentProperties());
     $this->assertEquals(new DocumentLayout(), $object->getLayout());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getSlide());
     $this->assertEquals(1, count($object->getAllSlides()));
     $this->assertEquals(0, $object->getIndex($slide));
     $this->assertEquals(1, $object->getSlideCount());
     $this->assertEquals(0, $object->getActiveSlideIndex());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Iterator', $object->getSlideIterator());
 }
All Usage Examples Of PhpOffice\PhpPresentation\PhpPresentation::getIndex