Util-Instance/src/InstanceIterator.php
2022-04-06 15:55:29 +02:00

56 lines
No EOL
1.4 KiB
PHP

<?php
/* {{{ Copyright and License Notice
*
* Copyright © 2022 RaBe Websolutions
*
* This file is part of rabe/Util-Instance.
*
* rabe/Util-Instance is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* rabe/Util-Instance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with rabe/Util-Instance. If not, see <https://www.gnu.org/licenses/>.
*
*///}}}
declare(strict_types=1);
namespace rabe\Util;
class InstanceIterator extends FilesystemIterator
{
private ?Instance $instance;
/**
*
*/
public function walk()
{
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
// var_dump($fileinfo->getFilename());
}
}
}
public function current()
{
if (!isset($this->instance)) {
$this->instance = new Instance(parent::current());
}
// var_dump($this);
return $this->instance;
}
public function next()
{
$this->instance = null;
parent::next();
}
}