for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mattbit\Flat\Storage;
use Mattbit\Flat\Model\Document;
use Mattbit\Flat\Storage\EncoderInterface;
class FilesystemIterator implements \Iterator {
/**
* @var EncoderInterface
*/
protected $encoder;
public function __construct(EncoderInterface $encoder, $path)
{
$this->encoder = $encoder;
$this->iterator = new \GlobIterator($path, \FilesystemIterator::CURRENT_AS_PATHNAME);
iterator
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
public function current()
$data = file_get_contents($this->iterator->current());
return $this->encoder->decode($data);
public function key()
return $this->iterator->key();
public function next()
return $this->iterator->next();
public function rewind()
return $this->iterator->rewind();
public function valid()
return $this->iterator->valid();
public function setIterator(\Iterator $iterator)
$this->iterator = $iterator;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: