PHP Class PHPExiftool\Reader

It scans files and directories, and provide an iterator on the FileEntities generated based on the results. Example usage: $Reader = new Reader(); $Reader->in('/path/to/directory') ->exclude('tests') ->extensions(array('jpg', 'xml)); Throws an exception if no file found $first = $Reader->first(); Returns null if no file found $first = $Reader->getOneOrNull(); foreach($Reader as $entity) { Do your logic with FileEntity }
Author: Romain Neutron ([email protected])
Inheritance: implements IteratorAggregate
Afficher le fichier Open project: romainneutron/PHPExiftool Class Usage Examples

Protected Properties

Свойство Type Description
$collection Doctrine\Common\Collections\ArrayCollection
$dirs
$excludeDirs
$exiftool
$extensions
$extensionsToggle
$files
$followSymLinks
$ignoreDotFile
$parser
$readers
$recursive
$sort

Méthodes publiques

Méthode Description
__construct ( Exiftool $exiftool, RDFParser $parser ) Constructor
__destruct ( )
all ( ) : ArrayCollection Perform the scan and returns all the results
append ( Reader $reader ) : Reader Append a reader to this one.
create ( Psr\Log\LoggerInterface $logger )
exclude ( string | array $dirs ) : Reader Exclude directories from scan
extensions ( string | array $extensions, boolean $restrict = true ) : Reader Restrict / Discard files based on extensions Extensions are case insensitive
files ( string | array $files ) : Reader Add files to scan
first ( ) : FileEntity Return the first result. If no result available, throws an exception
followSymLinks ( ) : Reader Toggle to enable follow Symbolic Links
getIterator ( ) : Iterator Implements \IteratorAggregate Interface
getOneOrNull ( ) : FileEntity Return the first result. If no result available, null is returned
ignoreDotFiles ( ) : Reader Ignore files starting with a dot (.)
in ( string | array $dirs ) : Reader Add dirs to scan
notRecursive ( ) : Reader Disable recursivity in directories scan.
reset ( )
sort ( string | array $by ) : Reader Sort results with one or many criteria

Méthodes protégées

Méthode Description
buildQuery ( ) : string Build query from criterias
buildQueryAndExecute ( ) : ArrayCollection Build the command returns an ArrayCollection of FileEntity
computeExcludeDirs ( string $rawExcludeDirs, $rawSearchDirs ) : array Compute raw exclude rules to simple ones, based on exclude dirs and search dirs
resetResults ( ) : Reader Reset any computed result

Method Details

__construct() public méthode

Constructor
public __construct ( Exiftool $exiftool, RDFParser $parser )
$exiftool Exiftool
$parser RDFParser

__destruct() public méthode

public __destruct ( )

all() public méthode

Perform the scan and returns all the results
public all ( ) : ArrayCollection
Résultat Doctrine\Common\Collections\ArrayCollection

append() public méthode

Finale result will be the sum of the current reader and all appended ones.
public append ( Reader $reader ) : Reader
$reader Reader The reader to append
Résultat Reader

buildQuery() protected méthode

Build query from criterias
protected buildQuery ( ) : string
Résultat string

buildQueryAndExecute() protected méthode

Build the command returns an ArrayCollection of FileEntity
protected buildQueryAndExecute ( ) : ArrayCollection
Résultat Doctrine\Common\Collections\ArrayCollection

computeExcludeDirs() protected méthode

Compute raw exclude rules to simple ones, based on exclude dirs and search dirs
protected computeExcludeDirs ( string $rawExcludeDirs, $rawSearchDirs ) : array
$rawExcludeDirs string
Résultat array

create() public static méthode

public static create ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

exclude() public méthode

Warning: only first depth directories can be excluded Imagine a directory structure like below, With a scan in "root", only sub1 or sub2 can be excluded, not subsub. root ├── sub1 └── sub2    └── subsub Example usage: Will scan documents recursively, discarding documents/test $Reader ->in('documents') ->exclude(array('test'))
public exclude ( string | array $dirs ) : Reader
$dirs string | array The directories
Résultat Reader

extensions() public méthode

Restrict / Discard files based on extensions Extensions are case insensitive
public extensions ( string | array $extensions, boolean $restrict = true ) : Reader
$extensions string | array The list of extension
$restrict boolean Toggle restrict/discard method
Résultat Reader

files() public méthode

Example usage: Will scan 3 files : dc00.jpg in CWD and absolute paths /tmp/image.jpg and /tmp/raw.CR2 $Reader ->files('dc00.jpg') ->files(array('/tmp/image.jpg', '/tmp/raw.CR2'))
public files ( string | array $files ) : Reader
$files string | array The files
Résultat Reader

first() public méthode

Return the first result. If no result available, throws an exception
public first ( ) : FileEntity
Résultat FileEntity

getIterator() public méthode

Implements \IteratorAggregate Interface
public getIterator ( ) : Iterator
Résultat Iterator

getOneOrNull() public méthode

Return the first result. If no result available, null is returned
public getOneOrNull ( ) : FileEntity
Résultat FileEntity

ignoreDotFiles() public méthode

Folders starting with a dot are always exluded due to exiftool behaviour. You should include them manually
public ignoreDotFiles ( ) : Reader
Résultat Reader

in() public méthode

Example usage: Will scan 3 dirs : documents in CWD and absolute paths /usr and /var $Reader ->in('documents') ->in(array('/tmp', '/var'))
public in ( string | array $dirs ) : Reader
$dirs string | array The directories
Résultat Reader

notRecursive() public méthode

If you only specify files, this toggle has no effect
public notRecursive ( ) : Reader
Résultat Reader

reset() public méthode

public reset ( )

resetResults() protected méthode

Reset any computed result
protected resetResults ( ) : Reader
Résultat Reader

sort() public méthode

Example usage: Will sort by directory then filename $Reader ->in('documents') ->sort(array('directory', 'filename')) Will sort by filename $Reader ->in('documents') ->sort('filename')
public sort ( string | array $by ) : Reader
$by string | array
Résultat Reader

Property Details

$collection protected_oe property

protected ArrayCollection,Doctrine\Common\Collections $collection
Résultat Doctrine\Common\Collections\ArrayCollection

$dirs protected_oe property

protected $dirs

$excludeDirs protected_oe property

protected $excludeDirs

$exiftool protected_oe property

protected $exiftool

$extensions protected_oe property

protected $extensions

$extensionsToggle protected_oe property

protected $extensionsToggle

$files protected_oe property

protected $files

$ignoreDotFile protected_oe property

protected $ignoreDotFile

$parser protected_oe property

protected $parser

$readers protected_oe property

protected $readers

$recursive protected_oe property

protected $recursive

$sort protected_oe property

protected $sort