<?php

namespace Zenoph\Notify\Collections;

class ComposerDestinationsList implements \Iterator {
    private $_items = null;
    private $_pointer = 0;

    public function __construct(&$destItems) {
        if (is_null($destItems) || !is_array($destItems))
            throw new \Exception('Invalid object reference for composer destinations list.');

        $this->_items = &$destItems;
    }

    // Implementing Iterator methods with correct return types
    public function current(): mixed {
        return $this->_items[$this->_pointer];
    }

    public function next(): void {
        $this->_pointer++;
    }

    public function key(): mixed {
        return $this->_pointer;
    }

    public function rewind(): void {
        $this->_pointer = 0;
    }

    public function valid(): bool {
        return isset($this->_items[$this->_pointer]);
    }

    public function getCount(): int {
        return count($this->_items);
    }
}
