<?php
 namespace ModulesAbstract\ImportedOrdersFileManager\Model\Sources; abstract class AbstractScanner implements \Iterator { protected $path = NULL; protected $recurse = null; protected $iterator = NULL; protected $current = NULL; protected $currentIndex = -1; protected $iterating = false; protected $totalNumberOfResults = NULL; protected $numberOfResults = NULL; protected $layoutHandler = NULL; protected $source = NULL; protected $shouldStop = false; public function setShouldStop($shouldStop) { $this->shouldStop = $shouldStop; return $this; } public function setLayoutHandler(\ModulesAbstract\ImportedOrdersFileManager\Model\LayoutHandler $layoutHandler) { $this->layoutHandler = $layoutHandler; return $this; } public function setSource(\Iterator $source) { $this->source = $source; return $this; } public function getSource() { return $this->source; } public function setParams($path, $recurse) { $this->path = $path; $this->recurse = (bool)$recurse; if ($this->recurse) { $this->iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path), \RecursiveIteratorIterator::SELF_FIRST); } else { $this->iterator = new \DirectoryIterator($this->path); } $this->rewind(); return $this; } public function getPath() { return $this->path; } public function getTotalNumberOfResults() { return $this->totalNumberOfResults; } public function getNumberOfResults() { return $this->numberOfResults; } public function current() :mixed { return $this->current; } public function key() :mixed { return $this->currentIndex; } public function next() :void { } public function rewind() :void { $this->iterating = false; $this->currentIndex = -1; if ($this->iterator) { $this->iterator->rewind(); } } abstract public function valid() :bool; } 